I am new to SQL, I tried to create a CTE, but I get a red squiggle under the AS and I am getting an error message in the process of executing the syntax:
Msg 102, Level 15, State 1, Line 117 Incorrect syntax near ')'.
This is the SQL syntax, any help would be great:
WITH CTE_Grand_Harvest_Total AS (SELECT zardi, COUNT(zardi) AS Count_ZARDI, SUM(Weight) AS Sum_Weight, Total_Harvest, Total_Harvest*COUNT(zardi)*SUM(Weight) AS Grand_TotalFROM S1_PH_CROPS_clean_final_minus_money_mattersWHERE Work.dbo.S1_PH_CROPS_clean_final_minus_money_matters.cropNamePH = 'Maize'GROUP BY Total_Harvest, zardi)