Posted by Sai, Jan. 4, 2024, 10:45 p.m.

10. Min and max spend

  • Write a query to return the minimum and maximum customer total spend in June 2020.
  • For each customer, first calculate their total spend in June 2020.
  • Then use MIN, and MAX function to return the min and max customer spend .

 

SELECT min(amount),max(amount)
FROM payment
GROUP BY extract(month from payment_ts) ,extract(year from payment_ts)
HAVING extract(month from payment_ts)=6 AND extract(year from payment_ts)=2020

 

can some one help me with the modifications i need to do get the desired output 

Answer

Answers


Comment
SQLPad user: Leon Wei

- Leon (934)

Jan. 12, 2024, 10:26 a.m.