Hello all!I have the following code which works very well except the Where Clause. I left some of the malfunctioning whereClause so that you can see what I am looking for: Wherever I get a value for [dateright] I want the value for [pcnextday] in a column. If there is no value for dateright then i dont want a row.The following is the data returned by the Statement without the whereClause:dateleft closeleft pcleft pcright dateright closeright pcnextday2000-01-03 6750.76 -3,03 NULL NULL NULL -2,372000-01-04 6586.95 -2,37 NULL NULL NULL -1,272000-01-05 6502.07 -1,27 NULL NULL NULL -0,42000-01-06 6474.92 -0,4 NULL NULL NULL 4,482000-01-07 6780.96 4,48 4,48 2000-01-07 6780.96 2,062000-01-10 6925.52 2,06 2,06 2000-01-10 6925.52 -0,52000-01-11 6891.25 -0,5 NULL NULL NULL 0,492000-01-12 6912.81 0,49 NULL NULL NULL 0,612000-01-13 6955.98 0,61 NULL NULL NULL 3,052000-01-14 7173.22 3,05 3,05 2000-01-14 7173.22 1,132000-01-17 7258.90 1,13 NULL NULL NULL -2,612000-01-18 7072.12 -2,61 NULL NULL NULL 0,362000-01-19 7091.04 0,36 NULL NULL NULL 0,23
Here I add the selectstatement:with cte as(select l.[date] as dateleft,l.[close] as closeleft,l.percentagechange as pcleft,r.[date] as dateright, r.[close] as closeright, r.percentagechange as pcright from dax2 l left join(select [date],[close], percentagechange from dax2 where percentagechange >2) ron l.[date] = r.[date])select dateleft, closeleft,pcleft,pcright, dateright,closeright, lead(pcleft) over(order by [dateleft]) as pcnextdayfrom ctewhere dateleft = dateright
The where Clause does not help me at all. The value returned from pcnextday is not accurate.Which is the correct way to get my needed data?Thank you very muchlandau