March 2, 2021 at 12:00 am
Comments posted to this topic are about the item Adding N/A
March 2, 2021 at 8:01 am
You can avoid COALESCE with this code:
SELECT *
,LAG(CAST(b AS VARCHAR(10)),1,'N/A')over(ORDER BY a,b)
FROM (VALUES
('a',1)
,('b',2)
,('c',3)
,('d',4)
) AS V([a],)
-- P.S. I did not test for performance.
March 2, 2021 at 12:09 pm
I suspect the 3rd parameter solution was what was being suggested in the first option - with the error of "NULL" instead of "LAG" in the answer. Of course your (Carlo's) answer goes beyond that to put in the CAST that will make it work, so even if the answer had been worded correctly it wouldn't be the right answer.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply