SQL GroupBy with Where clause

0

The below query returns any User who existed Where transaction_date > ‘3/1/2017′ and has sum(AMOUNT) > 3000 from all dates.

I want to return only users who have had sum(AMOUNT) > 3000 AFTER 3/1/2017. In other words, user needs to have sum(Amount) at least $3000 from only transactions after 3/1/2017.

 SELECT   User
 FROM     Source
 Where transaction_date > '3/1/2017'
 GROUP BY User
 HAVING   sum(AMOUNT) > 3000

Link: SQL GroupBy with Where clause
Source: Stack Sql

Share.

About Author

Leave A Reply