@nazone please help me with my sql
@nazone please help me with my sql
this is the erd databae
I am assuming here the SALES_LINE table has all the details about amount and we do not need to calculate anything from TICKET table.
Would that work for you @nazone?
WITH CTESales (TRANSACTION_NO, Sales) AS ( SELECT TRANSACTION_NO, SUM(LINE_PRICE) Sales FROM SALES_LINE GROUP BY TRANSACTION_NO ), CTESalesTotal (PAR_CODE,TotalSales) AS ( SELECT S.PAR_CODE,SUM(CS.SALES) TotalSales FROM CTESales CS JOIN SALES S ON S.TRANSACTION_NO = CS.TRANSACTION_NO GROUP BY S.PAR_CODE ) SELECT P.PARK_NAME, P.PARK_COUNTRY, COALESCE(CST.TotalSales,0) AS TotalSales FROM CTESalesTotal CST RIGHT JOIN THEMEPARK P ON P.PARK_CODE = CST.PAR_CODE WHERE P.PARK_COUNTRY IN ('FR','UK');
is there any way to simplify the coding sir?is it like this,, can u fix this cuz we have to make simplify the coding for one question
19 People are following this question.