sql - Get value for each date if not exist then take previous last updated value -
i have table have column employeeid, accountid,updated date. each row have data account if changes on date. if no change there no record accountid on date. example
employeeid accountid updateddate 1775 1 2010-12-04 00:00:00.000 1775 1 2010-08-13 23:59:59.000 1775 1 2010-08-13 00:00:00.000 1775 2 2010-12-04 00:00:00.000 1775 3 2010-12-04 00:00:00.000 1775 4 2010-12-04 00:00:00.000 1775 5 2010-12-04 00:00:00.000 1775 6 2010-12-04 00:00:00.000 1775 7 2010-12-04 00:00:00.000 1775 7 2010-06-29 23:59:59.000 i have value of each account each person on each day . if there no value on current day should take last update value previous day based on max update date value. , show result like
employeeid,date, values of each account. 1775;20120307;45;0;0;0;0;0;0;0;0;0;0;504;0;0;25.0;0.0;0.0;0.0;0.0;0.0;0.0;100;;;;; can 1 me?
you can either create table of dates , left join against that, or create dates dynamically described here: generate days date range
Comments
Post a Comment