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
vote
1 answer

SQL: Count of rows since certain value first occurred: keep counting

This is a similar scenario to SQL: Count of rows since certain value first occurred In SQL Server, I'm trying to calculate the count of days since the same weather as today (let's assume today is 6th August 2018) was observed first in the past 5…
Peete
  • 125
  • 11
1
vote
2 answers

LAG function behaviour on first row and group of repeated partition

I am trying to use the LAG() function in MSSQL and I am getting a weird behavior. The table looks like this: ID TotalReadings Month Device 0 1 4 January M 1 1 4 January D 2 1 4 …
tavalendo
  • 857
  • 2
  • 11
  • 30
1
vote
1 answer

SQL determine whether a customer issue is answered by the employee

I'm looking for a way to determine whether an employee has fixed the problem directly for a customer. When an employee needs to return within 7 days, the problem was not solved. Situations: The problem was solved immediately. Thus a positive…
1
vote
2 answers

r - calculate using next non-na value in data frame column

I have some data in a dataframe, and I would like to calculate the percentage change between the month value. The problem is I have NA in some entries and it throws of the calculation. irm code price pct.change 1 201807…
jvalenti
  • 604
  • 1
  • 9
  • 31
1
vote
0 answers

I installed a Facebook Standard Event Pixel "Lead" and its returning as "SuccessCall"?

I installed a Standard Event Pixel "Lead" and its returning as "SuccessCall" when instead I am looking for the "Lead" event? There is no reference to 'SuccessCall" in the entire website code but it is recognising it as if I physically installed…
1
vote
3 answers

oracle sql to retrieve followup dates from a preceding date

CREATE TABLE tst_tbl ( id NUMBER, last_name VARCHAR2 (50), first_name VARCHAR2 (50), dob DATE, register_dt DATE, register_loc VARCHAR2 (50), visit_dt DATE, …
G.Kol
  • 49
  • 5
1
vote
1 answer

How to get status of only 1 lead in a program with GetLeadsByProgramID endpoint?

I am using the GetLeadsByProgramID REST API endpoint to get the Leads with Status under a Program in Marketo. But is there any way where I can get the status of only 1 lead for a program?
1
vote
3 answers

Oracle SQL loop LEAD() through partition

I have a set that looks something like this ID date_IN date_out 1 1/1/18 1/2/18 1 1/3/18 1/4/18 1 1/5/18 1/8/18 2 1/1/18 1/5/18 2 1/7/18 1/9/18 I began by SELECT ID, date_IN, Date_out, lead(date_out) over ( partition by…
a.s.1
  • 39
  • 7
1
vote
3 answers

lag/lead entire dataframe in R

I am having a very hard time leading or lagging an entire dataframe. What I am able to do is shifting individual columns with the following attempts but not the whole thing: require('DataCombine') df_l <- slide(df, Var = var1, slideBy = -1) using…
Niccola Tartaglia
  • 1,537
  • 2
  • 26
  • 40
1
vote
0 answers

How to use Lead Automation functionality in Marketing Campaigns module Odoo V9?

Can someone explain me how marketing campaigns works in odoo9? After installing module there is one menu displayed called "Lead Automation". There is no documentation related to this module. I will be happy if someone explain me the whole process of…
1
vote
1 answer

lagging variables by day and creating new row in the process

I'm trying to lag variables by day but many don't have an observation on the previous day. So I need to add an extra row in the process. Dplyr gets me close but I need a way to add a new row in the process and have many thousands of cases. Any…
swhusky
  • 305
  • 3
  • 12
1
vote
1 answer

Doing rolling custom computations using data.table for multiple columns

I am doing rolling computations on a column,using the below code dt <- data.table(x1=1:8,x2=2:10,x3=4:11,x4=6:12) N = 3L dt[, y1 := (2*dt$x1[.I] -dt$x1[(.I+N-1L)]), by=1:nrow(dt)] dt x1 x2 x3 x4 y1 1: 1 2 4 6 -1 2: 2 3 5 7 0 3: 3 4…
ashleych
  • 1,042
  • 8
  • 25
1
vote
1 answer

SQL select items between LAG and LEAD using as range

Is it possible to select and sum items from a table using Lag and lead from another table as range as below. SELECT @Last = MAX(ID) from [dbo].[#Temp] select opl.Name as [Age Categories] , ( SELECT…
Prince
  • 43
  • 9
1
vote
1 answer

WHERE clause using to not select rows with timestamps 50ms either side of it?

I have part of a table like this: timestamp | Source ----------------------------+---------- 2017-07-28 14:20:28.757464 | Stream 2017-07-28 14:20:28.775248 | Poll 2017-07-28 14:20:29.777678 | Poll 2017-07-28 14:21:28.582532 |…
Harry
  • 41
  • 1
  • 2
1
vote
2 answers

SAS-use of lead function

Suppose the dataset has three columns Date Region Price 01-03 A 1 01-03 A 2 01-03 B 3 01-03 B 4 01-03 A 5 01-04 B 4 01-04 B 6 01-04 B 7 I try to get the lead…
Neal801
  • 305
  • 2
  • 13