I’m new here and new using SQL,
Came across this error while trying to extract years from my date column and SUM up the Bag net weight per local ref, grouped by Year.
Here the script:
SELECT
extract(year FROM date()) AS YEAR,
count(Reception_lot_id) AS Lot_per_Ref,
SUM(Bag_N_WKG)
FROM
(
SELECT
DISTINCT
Local_Job_Ref
FROM
origin.tr2
WHERE
Local_Job_Ref IS NOT NULL
) Lot_per_Ref
WHERE
Local_Job_Ref IS NOT NULL
group by
year
Since I’ getting started I didn’t try much to solve this.
New contributor
PEMBE BUSHEBU is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1