Questions tagged [lead]

Accesses data from a subsequent row in the same result set without the use of a self-join in SQL Server 2017. LEAD provides access to a row at a given physical offset that follows the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a following row.

For further reading https://learn.microsoft.com/en-us/sql/t-sql/functions/lead-transact-sql

309 questions
-1
votes
1 answer

For looping over dates

So I have a dataframe called Swine_flu_cases that looks as follows (just an extract): Country Date Confirmed 1 Canada 2020-01-22 1 2 Egypt 2020-01-23 1 …
DRC_mami
  • 3
  • 3
-1
votes
1 answer

sql sum 2 column values and sort records by 3 columns

I have columns - ip, port, pair, pair_status, length, length_to_fault, add_date. I need to sort everything by port, and each port has a pair(A,B,C,D) atleast once. when its sorted, i need to sort even more - i need to sort each pair in exact…
Cris
  • 17
  • 8
-1
votes
1 answer

How to create churn table from transactional data?

Currently my Transaction Table has customer's transaction data for each month. Account_ID identifies the customer's ID. Order_ID is the number of orders that the customer had made. Reporting_week_start_date is the week which begins on Monday where…
Shang Rong
  • 77
  • 1
  • 1
  • 6
-1
votes
1 answer

How to return a result set with non- overlapping start and end dates from given tables

SELECT * FROM dim_date ds 2018-01-01 2018-01-02 2018-01-03 ... ... SELECT * FROM "fact_metrics$partitions" ds 2018-01-04 2018-01-05 2018-01-06 ... ... 2018-08-23 ... ... Suppose *fact_metrics *has a data pipeline that is scheduled daily and…
SelectStarFrom
  • 141
  • 1
  • 2
  • 8
-1
votes
1 answer

Field mapping result insert into mysql database

I am trying to finish the last function of a script that sync data added in Facebook lead form to MySQL database. I am trying to map MySQL columns to Facebook lead form fields then when new entry added in Facebook lead each content to be added to…
-1
votes
1 answer

How can i initialize the Source Type from Lead to Opportunity

It is possible to qualify a lead, when a lead is qualified a new opportunity is created. In the lead dialog it is possible to fill in a Source Type and Source ID. I want to fill in the opportunity I make from the lead, in this case: If I fill in a…
Mark Van
  • 281
  • 4
  • 21
-2
votes
0 answers

How to use LAG & LEAD FUNCTION in SQL SERVER 2008

i code query on SQL Server 2019. I have problem about Lead & Lag on SQL Server 2008. Here my query. SELECT DAT_PASIEN, REG_KUNJUNGANPASIEN, TGL_REGISTRASI, LEAD(TGL_REGISTRASI) OVER (ORDER BY TGL_REGISTRASI DESC) NEXT_TGL_REGISTRASI, …
-2
votes
1 answer

SQLite Studio query works different when I make it a subquery

I'm using the Superstore_test dataset here: https://www.kaggle.com/blurredmachine/superstore-time-series-dataset I want to make a column that shows the sales of the next row down. I put this query in and I get very odd results where some rows are…
Tynan
  • 9
  • 1
-2
votes
2 answers

how to count number of records from 3rd day to 62nd day for each person by using SQL query?

I want to get the count of 'unitsold' for each Name from 3/1/2022 and 4/1/2022. For example Name 'a' required to count its units sold from 3rd to 8th day. SQL query: select Name, sum(unitsold) over (partion by Name order by Asc) from table1 The…
Sanky Ach
  • 333
  • 8
  • 23
1 2 3
20
21