I'm not sure if there's even a function for this, but lets say that you had a column like:
20
20
55
55
55
60
72
72
Is there a SQL query that would give you:
20 0
20 1
55 0
55 0
55 1
60 1
72 0
72 1
Basically, create a new column that would make all the values 0 except it makes the last value 1.
So what I have right now is:
ALTER TABLE {TABLENAME}
ADD {COLUMNNAME} INT NOT NULL
CONSTRAINT zero DEFAULT 0
And then I need a function that selects all the last values and then I can use an update table function to change tablename=1 for all of those values. If it makes a difference, I'm using SQL Server 2008.