Hi,I have a table datetest having the recordsDat Value2004-11-10 00:00:00.000 12004-11-11 00:00:00.000 32004-11-12 00:00:00.000 232004-11-14 00:00:00.000 72004-11-16 00:00:00.000 87I want to generate the missed dates with value 0. My desired output isDat Value2004-11-10 00:00:00.000 12004-11-11 00:00:00.000 32004-11-12 00:00:00.000 232004-11-13 00:00:00.000 02004-11-14 00:00:00.000 72004-11-15 00:00:00.000 02004-11-16 00:00:00.000 87I used the following query select distinct * from datetestunionSelect distinct * from(select (Select case when t1.dat-t2.dat=1 then t1.dat-1 else t2.dat end as new from datetest t1where t1.dat-t2.dat=1) dat,0 valuefrom datetest t2 unionselect(Select case when t1.dat-t2.dat=2 then t1.dat+1 else t2.dat end as new from datetest t1where t1.dat-t2.dat=2) dat,0 valuefrom datetest t2 ) t1 where dat is not null
which produced the result2004-11-10 00:00:00.000 02004-11-10 00:00:00.000 12004-11-11 00:00:00.000 02004-11-11 00:00:00.000 32004-11-12 00:00:00.000 232004-11-13 00:00:00.000 02004-11-14 00:00:00.000 72004-11-15 00:00:00.000 02004-11-16 00:00:00.000 872004-11-17 00:00:00.000 0From this I want the required resultBut this query will work only if the difference between successive dates is 1Is there any generalised way?Madhivanan