3
I want in a "Test" column to define the value "S" for only in the first row of a given "code" and all the others to define the value "N" and so successively for all other codes in a SELECT, I am using SQL SERVER.
ID COD VLR DATA TESTE
01 123 100 "06/09/2015" S
04 123 400 "03/09/2015" N
05 123 500 "02/09/2015" N
02 456 200 "05/09/2015" S
03 456 300 "04/09/2015" N
06 789 600 "01/09/2015" S
Note: I verified that it has the functions LAG and LEAD, but I could not do it using them.
Thank you for your attention.
Let me get this straight. You want to make a
update
where all rows (except the first) have the column value test as opposed to the value of the first line?– Jéf Bueno
@Jéfersonbueno It would not be an Update, it would be in a Select even...
– Roberto Valentim