Home > database >  After computing group in time
After computing group in time

Time:01-01

, every brother please help me this small white,,,
Now have a data below
I want to calculate the time difference between two customers under the same ID (in) the absolute value of, how can I write ah, thanked first here,

CodePudding user response:

 
WITH CTE
AS
(SELECT *, Row_Number () OVER (partition by ID ORDER by DT ASC) rank the FROM dbo. Customer)
SELECT Anderson D, DATEDIFF (MONTH, a. d. T, b.D T) FROM CTE JOIN a CTE ON Anderson, D=b b.I D AND a.r ank=b.r ank - 1

CodePudding user response:

Thank you for big grant instruction
  • Related