By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version() |
---|
8.0.36 |
WITH
supermarket_sales (DATE_STR, VAL) AS
( Select '01/17/2019', 548.971 Union All
Select '03/15/2019', 80.22 Union All
Select '03/19/2019', 340.526 Union All
Select '01/24/2019', 489.048 Union All
Select '02/21/2019', 634.378 Union All
Select '03/07/2019', 627.617 Union All
Select '02/21/2019', 433.692 Union All
Select '02/21/2019', 772.38 Union All
Select '01/26/2019', 76.146 Union All
Select '02/27/2019', 172.746 Union All
Select '02/28/2019', 60.816
)
SELECT MonthName( Str_To_Date( DATE_STR, '%m/%d/%Y' ) ) AS month,
Year( Str_To_Date( DATE_STR, '%m/%d/%Y' ) ) AS year,
Sum(VAL) as total
FROM supermarket_sales
GROUP BY year, month
month | year | total |
---|---|---|
January | 2019 | 1114.165 |
March | 2019 | 1048.363 |
February | 2019 | 2074.012 |