Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH MaxPerDay as (
- SELECT
- CustomerID,
- CONVERT(VARCHAR, STARTDATE, 105) as 'Day',
- MAX(SCORE) as 'MaxScore'
- FROM
- Interactions
- GROUP BY CustomerId, CONVERT(VARCHAR, STARTDATE, 105)
- )
- SELECT
- MaxPerDay.CustomerID,
- SUM(MaxPerDay.MaxScore)
- from MaxPerDay
- GROUP BY MaxPerDay.CustomerID
- order by SUM(MaxPerDay.MaxScore) desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement