sql server 2008 - sql to remove repeating data -
i have problem data need filter out produce report.
basically every day take file , load system file cumulative file , re imported same information plus new data daily.
this loads database 2 tables, header , detail table.
in header table have key filed of no_, date imported , month , year data (period) example 'apr2013'.
the detailed table holds of information import can imagine.
what i'm looking disregard of older data , @ recent import month only.
hopefully can me, if want me post example data or please let me know , i'll add in.
thanks in advance!
phil
if cannot change process stop re-importing same data on , on - if data is same - try following query:
with mostrecentdata ( select max(dateimported) dateimported, month, year header group month, year ) select ... detail d inner join header h on h.[key] = d.[key] inner join mostrecentdata r on h.month = r.month , h.year = r.year , h.dateimported = r.dateimporter
this pull out latest rows (based on date imported) each month , year.
honestly though try change import process if possible. sounds lot of wasted space , subsequent processing pull out data want.
Comments
Post a Comment