Skip to content

Commit 7e3c18f

Browse files
authored
Update README.md
1 parent 420445b commit 7e3c18f

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

README.md

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,81 @@
88
* what is the total retail sales for each supplier?
99

1010
QUERY:
11-
![image](https://user-images.githubusercontent.com/100838547/224489252-b4907cbb-ec04-449d-90fc-78a64874a903.png)
12-
11+
```sql
12+
select supplier, sum(retailsales) as total_retail_sales
13+
from project
14+
group by supplier;
15+
```
1316
RESULT:
1417

1518
![supply](https://user-images.githubusercontent.com/100838547/224489292-87e0be9c-c732-4b43-8bf8-565bbc054124.png)
1619
* what is the total retail sales for each combination of supplier and month
1720

1821
QUERY:
19-
20-
![image](https://user-images.githubusercontent.com/100838547/224489809-dd3ed56a-9d34-4d49-af5f-f946ffc23ae9.png)
21-
22-
22+
```sql
23+
select supplier, year, month, sum(retailsales) as total_retail_sales
24+
from project
25+
group by supplier, year, month;
26+
```
2327
RESULT:
2428

2529
![S2](https://user-images.githubusercontent.com/100838547/224490032-fcd48f03-6b2a-4a76-a0f8-f4d74d25819d.png)
2630

2731
* what is the maximum warehouse sales for each item description?
2832

2933
QUERY:
30-
![image](https://user-images.githubusercontent.com/100838547/224490206-05217b28-21c9-4d4d-8285-40514de9a18e.png)
31-
34+
```sql
35+
select itemdescription, max(retailsales) as max_warehouse_sales
36+
from project
37+
group by itemdescription;
38+
```
3239
RESULT:
3340

3441
![S3](https://user-images.githubusercontent.com/100838547/224490291-90dffa9b-fa4e-4514-8df8-5f2ffbb4cb28.png)
3542

3643
* what is the average retail transfer for each year
3744

3845
QUERY:
39-
![image](https://user-images.githubusercontent.com/100838547/224490403-6237613c-5cbb-49de-bed1-2c8238a72583.png)
46+
```sql
47+
select year, avg(retailtransfers) as avg_retail_transfers
48+
from project
49+
group by year;
50+
```
4051

4152
RESULT:
4253

4354
![S4](https://user-images.githubusercontent.com/100838547/224490466-0d7f489f-88b2-4aad-8156-c5072dd131ca.png)
4455

4556
* for each item description, what is the difference between the maximum and minimum retail sales?
4657
QUERY:
47-
![image](https://user-images.githubusercontent.com/100838547/224490673-9d03f8ac-6d80-4380-9798-eb72a39fb24f.png)
48-
58+
```sql
59+
select itemdescription, max(retailsales) - min(retailsales) as diff_max_min_retail_sales
60+
from project
61+
group by itemdescription;
62+
```
4963
RESULT:
5064

5165
![S5](https://user-images.githubusercontent.com/100838547/224490734-631015ab-8936-4c4a-9c73-3e3a399d0b68.png)
5266

5367
* what is the total retail sales for each supplier, broken down by year and month
5468

5569
QUERY:
56-
![image](https://user-images.githubusercontent.com/100838547/224491141-5c06e507-4b74-44ab-8687-8aa280bbe7d1.png)
57-
RESULT:
70+
```sql
71+
select year, month, supplier,
72+
sum(retailsales) over (partition by supplier, year, month) as total_retail_sales
73+
from project;
74+
```
5875

76+
RESULT:
5977
![S6](https://user-images.githubusercontent.com/100838547/224491227-92c48a4c-6169-4b7e-9375-3d224715f18c.png)
6078

6179
* what is the running total of retail sales for each item type, order by month?
6280
QUERY:
63-
![image](https://user-images.githubusercontent.com/100838547/224491440-96150a79-b1a3-4807-a64d-e34b52c60d14.png)
81+
```sql
82+
select year, month, itemtype,
83+
sum(retailsales) over (partition by itemtype order by month) as running_total_retail_sales
84+
from project;
85+
```
6486

6587
RESULT:
6688

@@ -69,7 +91,11 @@ RESULT:
6991

7092
* what is the difference in retail sales between each month and the previous month, for each supplier and item type?
7193
QUERY:
72-
![image](https://user-images.githubusercontent.com/100838547/224491732-f5aa07e3-cc20-430b-be2c-39378579a454.png)
94+
```sql
95+
select year, month, supplier, itemtype,
96+
retailsales - lag(retailsales) over (partition by supplier, itemtype order by year, month) as diff_retail_sales
97+
from project;
98+
```
7399

74100
RESULT:
75101

0 commit comments

Comments
 (0)