SOLVED

Lead function error

Copper Contributor
Hi,
I have lead function after on clause as one of the conditions in join
Gives an error to me as "misuse of window function lead()"

Pls help
2 Replies
best response confirmed by Neha11 (Copper Contributor)
Solution

@Neha11 , a Windows function like LEAD is a post operation, you can not use it in a JOIN condition or in a WHERE clause, only in the SELECT clause.

 

One way round is to use a CTE = Common Table Expression to re-use the query result.

 

Olaf

Hi,
@olafhelper, thanks for the reply, I understood the concept
1 best response

Accepted Solutions
best response confirmed by Neha11 (Copper Contributor)
Solution

@Neha11 , a Windows function like LEAD is a post operation, you can not use it in a JOIN condition or in a WHERE clause, only in the SELECT clause.

 

One way round is to use a CTE = Common Table Expression to re-use the query result.

 

Olaf

View solution in original post