-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUDGET SQL QUIERS.sql
More file actions
30 lines (25 loc) · 847 Bytes
/
Copy pathBUDGET SQL QUIERS.sql
File metadata and controls
30 lines (25 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-----------Total Sales by Year
SELECT YEAR(OrderDate) AS Year, SUM(SalesAmount) AS TotalSales
FROM Sales
GROUP BY YEAR(OrderDate);
-----------Total Sales by Product
SELECT P.ProductName, SUM(S.SalesAmount) AS TotalSales
FROM Sales S
JOIN Product P ON S.ProductKey = P.ProductKey
GROUP BY P.ProductName;
-----------Customer Information
SELECT CustomerKey, FirstName, LastName, YearlyIncome, TotalChildren, NumberCarsOwned
FROM Customers;
-----------Sales by Customer Demographics
SELECT C.Gender, C.Education, SUM(S.SalesAmount) AS TotalSales
FROM Sales S
JOIN Customers C ON S.CustomerKey = C.CustomerKey
GROUP BY C.Gender, C.Education;
-----------Sales Distribution by Order Quantity
SELECT
OrderQuantity,
COUNT(*) AS NumberOfOrders,
SUM(SalesAmount) AS TotalSalesAmount
FROM Sales
GROUP BY OrderQuantity
ORDER BY OrderQuantity;