tsql - Grouping by date difference/range -
how write statement make specific group by's looking @ monthly date range/difference. example:
org_group | date | second_group_by 30.10.2013 1 29.11.2013 1 31.12.2013 1 30.01.2015 2 27.02.2015 2 31.03.2015 2 30.04.2015 2
as long es there isnt monthly date_diff > 1
should in same second_group_by. hope clear enough understand, column second_group_by should generated user...it doesnt exists in table.
date diff between rows though? if want separate years (or months or weeks) use group datepart(....)
that's sybase or sql server other sqls have equivalent.
if have specific data ranges, them table start , end date-time , monotonically increasing integer, join between , group integer.
Comments
Post a Comment