I have a table. I want to compare each row with next row till all rows. If matched I need to display only mismatch values.
TABLE_A
-
A B C -
A B D -
E A E -
A C E
.. .. .. nth
Output should be
-
A B C -
NULL NULL D -
E A E -
A C NULL
.. .. .. nth
I have a table. I want to compare each row with next row till all rows. If matched I need to display only mismatch values.
TABLE_A
A B C
A B D
E A E
A C E
.. .. .. nth
Output should be
A B C
NULL NULL D
E A E
A C NULL
.. .. .. nth
Take a look at the SQL Lag function. This website explains how it works. Example 1 is very clear https://www.sqlshack.com/sql-lag-function-overview-and-examples/
SELECT *, Lag(JoiningDate, 1) OVER(. ORDER BY JoiningDate ASC) AS EndDate FROM @Employee;
makes: