79403060

Date: 2025-01-31 14:39:06
Score: 1
Natty:
Report link

I would use date_trunc to filter the year rather than extract.

SELECT 
p.product_name 
,SUM(s.sale_amount) AS total_sales
FROM 
Sales s
JOIN Product p
ON s.product_id = p.product_id
WHERE 
s.sale_date >= DATE_TRUNC('year', CURRENT_DATE)
GROUP BY 
p.product_name
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jose A