Example2: Customers of any Store


If you have to make Marketing tactics to increase sales to reach the sales targets, you should know where is your customers.

In this example, I will determinate customer's cities of the store 13.

SELECT
S1997.store_id AS ID,
C.city AS CI,
C.country AS CO,
SUM(S1997.store_sales * S1997.unit_sales) AS SALES,
SUM(S1997.store_cost * S1997.unit_sales) AS COSTS

FROM
sales_fact_1997 S1997,
customer C

WHERE
S1997.customer_id = C.customer_id
AND
S1997.store_id = 13

GROUP BY
S1997.store_id,
C.city,
C.country

ORDER BY
4 DESC;
ID	CI	CO	SALES	COSTS
14	Burlingame	USA	775,94	304,8039
14	Fremont	USA	662,48	267,4287
14	Santa Cruz	USA	658,42	266,1397
14	Novato	USA	655,5	265,594
14	San Jose	USA	607,74	246,5625
14	Berkeley	USA	586,59	237,1897
14	San Carlos	USA	549,04	221,7154
14	Colma	USA	534,72	212,9925
14	Redwood City	USA	531,61	210,6034
14	Palo Alto	USA	495,14	198,7779
14	Daly City	USA	491,38	201,4721
14	Concord	USA	417,31	164,9573
14	San Francisco	USA	349,34	144,3894
14	Richmond	USA	347,01	130,2938
14	Oakland	USA	247,56	102,2115
14	Mill Valley	USA	182,02	72,9039

To see the example in action, Example2