小编Jef*_*ott的帖子

Min/Max Date Values over Large Date Range depending on Value

I'm querying a snapshot of customer data that contains the snapshot date, the customer ID and the 'value' of that customer on that day. I use the LAG function to return the previous days value to know if there is a drop/rise/complete loss/complete new value (from £0 to > £0).

The end game is to identify the min and max dates where the customer was at £0 value.

Originally I tried MIN(Date) and Max(Date) grouping by the Customer and Value. …

sql t-sql sql-server gaps-and-islands

8
推荐指数
1
解决办法
84
查看次数

标签 统计

gaps-and-islands ×1

sql ×1

sql-server ×1

t-sql ×1