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
0
votes
0 answers

Fill backward a number of rows in SAS

I need to create a variable that fills one cell 10 observations backward and one forward in SAS. A condition must be met. It is hard to explain, so the data below might help. So far I tried to use proc expand to generate 10 leads and get them into…
MaBo88
  • 97
  • 1
  • 1
  • 9
0
votes
1 answer

How to generate new Lead with button wizard?

I'm trying to add a button "Generate new Lead" inside a calendar event that copy's everything about this opportunity and creates a new Lead with the same data and hours of the event. this is my .py class AnserCopy(models.TransientModel): _name =…
0
votes
1 answer

lead keep and case

*Edit I have the below table: Table W No action_dt type status 1 5/6/2008 10:55:11 PM CREATE APPROVED 1 1/3/2013 9:52:01 AM UPDATE APPROVED 1 1/3/2013 9:57:26 AM UPDATE APPROVED 1 4/21/2015 2:19:04 PM …
John
  • 289
  • 3
  • 14
0
votes
0 answers

Facebook SDK - Get details of a lead - ASP .net core API

What i try to do is retrieve my facebook leads from my facebook page in a webhook ASP.net core API , get the lead details and save it in my mongoDB Database. I had a problem getting my lead details in the API because of the token. And then i saw in…
0
votes
3 answers

Apply lead function on the first value

So I used the lead function and it works great for leading the values of rows 2 and 3 as you can see below Here is the code to generate that table in sql. drop table timetable; create table timetable( names varchar(50), timestart…
Nick Ani
  • 1
  • 1
0
votes
1 answer

Creating start and end dates

I have the below table Createdt Updatedt id 1/1/2019 3/1/2019 1 1/1/2019 5/1/2019 1 1/1/2019 7/1/2019 1 Expected results: Createdt Start_dt_cycle End_dt_cycle id 1/1/2019 1/1/2019 2/28/2019 1…
Mr John
  • 231
  • 1
  • 3
  • 18
0
votes
1 answer

lag() and lead() in base-R

I'm used to using dplyr's lag() and lead() in my code, but I'm wondering -- is there a base R alternative? For example, assume the following dataframe: df<-data.frame(a=c("a","a","a","b","b"),stringsAsFactors=FALSE) Using dplyr, I could do this to…
iod
  • 7,412
  • 2
  • 17
  • 36
0
votes
1 answer

Sorting column A based on a column B which contains previous values from column A

I'd like to sort column A based on a column B which contains previous values from column A. This is what I have: +----+----------+----------+ | ID | A | B | +----+----------+----------+ | 1 | 17209061 | | | 2 | 53199491 |…
Dontik
  • 11
  • 1
  • 5
0
votes
2 answers

Overlaping dates

*Edit - No update rights. I have the below tables: An id should be associated to one area only. There's overlap on TableB. Therefore John on 1/9/19 is associated to area East and MidEast. Can I manipulate TableB to fix the overlapping? So, the…
Mr John
  • 231
  • 1
  • 3
  • 18
0
votes
1 answer

Take previous results and add to row

I have the below table results. Criteria: Partition by CUSTID and ITEMID Where end_dt is not null If the RESP column is null then take the latest value that has an entry. CUSTID ITEMID START_DT END_DT RESP START_CYCLE END_CYCLE 1 …
Mr John
  • 231
  • 1
  • 3
  • 18
0
votes
2 answers

LAG and the first NULL

I have the below table: id date cust 1 3/13/2019 1 3/14/2019 Johnson 1 3/19/2019 I want to create a column that captures the last cust entry and partition by id. I have the below.. select * ,case when a.cust is not null…
Mr John
  • 231
  • 1
  • 3
  • 18
0
votes
5 answers

Get next row not working from selected based on date time

I have the following data and I want to be able to put all the rows into one line based on the stop type id. So a stop type is in order which means a 0 or 2 will come before a 3. I believe Lead is what I want to use, but doesn't seem to be working…
JohnK
  • 35
  • 8
0
votes
1 answer

Implementation of lag function by updating the same column

I've to update the lag value of barcode (offset=1) to barcode case when ( lag(barcode,1) over (order by barcode ) and Datediff(SS, eventdate,lag(next_eventdate,1) over (order by barcode)) < 3*3600 ) THEN 1 ELSE 0 END as FLAG…
Katelyn Raphael
  • 253
  • 2
  • 4
  • 16
0
votes
2 answers

Oracle LEAD - return next matching column value

I having below data in one table. And I want to get NEXT out data from OUT column. So used LEAD function in below query. SELECT ROW_NUMBER,TIMESTAMP,IN,OUT,LEAD(OUT) OVER (PARTITION BY NULL ORDER BY TIMESTAMP) AS NEXT_OUT FROM MYTABLE; It gives…
usersam
  • 1,125
  • 4
  • 27
  • 54
0
votes
4 answers

How to concat cells from same table but different row?

I have the following problem. I have some rows in my table which are nearly the same and i need some cells to concat with cells above. My current Select statement looks like this: Select bltgs1, bltgs2, bltgs3, bltgs4, bltgs5, bltgs6, bltugp …
F.Gradl
  • 39
  • 10