Skip to content
Advertisement

SQL query to find minimum difference between row values of a column

I am trying to find the minimum difference between years for each ID. For example,

I have this data:

and I want this output:

Advertisement

Answer

You could use a LEFT JOIN

Online Demo

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement