THIS QUERY REVEALS WHAT IS THE STRUCTURE OF THE TABLE.
DESCRIBE SALES;
THIS QUERY REVEALS WHAT IS THE TOTAL SALES PER YEAR.
SELECT A.YEAR ,SUM( A.QUANTITY*A.PRICE) AS SALES FROM SALES A GROUP BY A.YEAR;
THIS QUERY IS USED TO SHOW THE SALES PER YEAR COLUMN WISE.
SELECT
SUM(DECODE(S.YEAR,2010, S.QUANTITY*PRICE)) SALES_2010,
SUM(DECODE(S.YEAR,2011, S.QUANTITY*PRICE)) SALES_2011,
SUM(DECODE(S.YEAR,2012, S.QUANTITY*PRICE)) SALES_2012
FROM PRODUCTS P, SALES S
WHERE (P.PRODUCT_ID = S.PRODUCT_ID)
GROUP BY P.PRODUCT_NAME;
No comments:
Post a Comment