1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| create Table T_histo_hst
(hst_param Int,
Hxt_date Datetime,
Hst_statut Bit)
Insert Into T_histo_hst Values (2, '1999-12-08', 0)
Insert Into T_histo_hst Values (3, '2002-04-02', 0)
Select T1.hxt_date As Date_min, T1.hst_param,
Coalesce(max(t2.hxt_date), '1900-01-011') - 1 Day As Date_max
From T_histo_hst T1
Left Outer Join T_histo_hst T2
On T1.hxt_date > T2.hxt_date
Group By T1.hxt_date, T1.hst_param
Date_min Hst_param Date_max
------------------------------------------------------ ----------- ------------------------------------------------------
1999-12-08 00:00:00.000 2 1900-01-10 00:00:00.000
2002-04-02 00:00:00.000 3 1999-12-07 00:00:00.000 |
Partager