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://docs.microsoft.com/en-us/sql/t-sql/functions/lead-transact-sql

228 questions
3
votes
1 answer

How to get the next next to last value if previous value is null

I am trying to clean up a table that basically fill up all the empty value from the 1st non-null value. The sample table: ID Number Type 1 51280 % 1 A 2 51279 % 2 B 3 50631 % 3 A 3 B 3 C There is…
MrMuffin
  • 45
  • 1
  • 5
3
votes
5 answers

apply lag or lead in increasing order for the dataframe

df1 <- read.csv("C:/Users/uni/DS-project/df1.csv") df1 year value 1 2000 1 2 2001 2 3 2002 3 4 2003 4 5 2004 5 6 2000 1 7 2001 2 8 2002 3 9 2003 4 10 2004 5 11 2000 1 12 2001 2 13 2002 …
Robby star
  • 255
  • 1
  • 9
3
votes
1 answer

How to get leads details in SalesForce with the REST API?

Is it possible, with the REST API available from SalesForce, to get the list of all leads and all their details?
herve
  • 369
  • 4
  • 12
3
votes
3 answers

What's the R equivalent of Stata's _n function?

I am wondering whether there is a function in R like in Stata, where you are able to use the value of the observation n numbers before or after each observation. For instance if I need to multiply or divide with the observation before I would write…
3
votes
1 answer

Finding difference in months using analytical function in oracle

I have data like below. In this I need to find rows where the diff in their months should be >= 6. The logic should be, we need to compare from first row until we got the row where diff in months is 6, then need to follow the same logic from the…
arunb2w
  • 1,090
  • 6
  • 26
3
votes
9 answers

What does your team do to stand out?

Where I work, we have small teams of 2 - 5 people. As a dev lead, what are some things that you've implemented which makes your team stand out from the others? Meaning, it makes the others teams say, "that's cool" or "why didn't we think of that".…
4thSpace
  • 41,122
  • 88
  • 267
  • 450
2
votes
1 answer

How to make a lead have multiple opportunities on SugarCRM 6.3 CE?

I need to make a lead convert (and relate to) 1 or more opportunity on SugarCRM. With just one lead it's easy, I just have to set the 'opp_id' field - however, with multiple leads I'm not able to do that. I need at least to create a relationship…
Lucas Famelli
  • 1,337
  • 2
  • 13
  • 22
2
votes
1 answer

Effcient shifting in R data.table with missing values

I have a data.table with the following three variables receptionist = id of the reception person week.no = this week's number (1 means first week) absent.thisweek = number of days absent this week Note that we only have data for the weeks…
vivek
  • 151
  • 13
2
votes
2 answers

Get the first non zero digit in R similar to Mathematica

In mathematica we have RealDigits that can identify the first non-zero number for both numbers with decimal point and integer values. See below as an example: RealDigits[ 0.00318, 10, 1] {{3},-2} RealDigits[ 419, 10, 1] {{4},-2} In the above…
forecaster
  • 946
  • 1
  • 10
  • 30
2
votes
2 answers

Leading vector taking values based on future values of another vector

I have a sequence of treatments, one per day (binary), say: trt <- c(0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0) I want to create a new vector, which corresponds to each element of trt and indicates whether the NEXT three treatments are all 0. For example,…
bob
  • 408
  • 3
  • 16
2
votes
1 answer

MYSQL difference between two datetime

I have the following table. table1: id_user | action | time --------+--------+---------------------- 1 | 2 | '2009-05-18 11:45:42' 1 | 2 | '2009-05-18 11:45:45' 1 | 3 | '2009-05-18 11:45:50' 1 | 2 |…
2
votes
5 answers

Choosing a single row based on multiple criteria

Can anyone think how to how to do this in R? Simple data: seq<-c("A","A","A","B","B","B","B") rank<-c(1,2,3,1,2,3,4) match<-c("y","n","y","n","n","y","y") df<- as.data.frame(cbind(seq,rank,match)) seq rank match 1 A …
2
votes
1 answer

Using lead with dplyr to compute the difference between two time stamps

I want to find the difference between two time stamps based on finding the time stamp in one column based on a condition, "Start", and then finding the time stamp for the first row that meets another condition in that same column, "Stop". Basically…
2
votes
2 answers

Lead and case expression

I have this table: ID Date ----------------- 1 1/1/2019 1 1/15/2019 Expected output: ID DATE LEAD_DATE ------------------------- 1 1/1/2019 1/14/2019 1 1/15/2019 SYSDATE SQL: SELECT *, CASE WHEN LEAD…
Mr John
  • 217
  • 2
  • 15
2
votes
2 answers

How to add a flag to the rows after a specific value within a key in Oracle SQL?

I have the following data: Key Stage CreateDate AAF 0 01-Jan-2018 AAF 0 02-Jan-2018 AAF 0 10-Jan-2018 AAF 20 20-Jan-2018 AAF 40 20-Mar-2018 AAF 0 01-May-2018 AAF 0 10-May-2018 AAF 0 20-May-2018 AAF 30 20-Jun-2018 AAF…
CuriP
  • 63
  • 9
1
2
3
15 16