I’m a beginner in SQL and I have the following problem in SQL.
I need an SQL query that would calculate the difference between two continuous rows having the same value in field [idpersone] and regroupe them into a single row.
For example I need to transform my table to the desired data as shown below:
Table data:
idLigne | idperson | statut
--------|----------|-------
L1 1 A
L2 1 B
L3 1 A
L4 1 B
L5 2 A
L6 2 B
L7 3 A
L8 3 B
Desired output:
idLigne | idpersonne | firstLighe | secondLigne
--------|------------|------------|------------
L2-L1 1 L1 L2
L4-L3 1 L3 L4
L6-L5 2 L5 L6
L8-L7 2 L7 L8
You might try something like this:
Result: