-
Notifications
You must be signed in to change notification settings - Fork 3
/
Projeto Scale Model Sales.sql
51 lines (29 loc) · 2.18 KB
/
Projeto Scale Model Sales.sql
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SELECT * FROM orders;
SHOW tables
DESCRIBE tables
/** Question to be answered **/
/** The number of products sold by category and by month, with comparison and rate of change compared to the same month of the previous year.**/
SELECT * FROM products;
/** By observing the available data we can classify the products by the following categories:
1- product line (if it is a car, airplane, boat)
2- product scale (smallest to biggest, from 1:700 to 1:10)
3 -product vendor (basically the distributor) **/
/** Afterwards lets have a look at the monhtly sales figures **/
SELECT*FROM orders;
SELECT*FROM orders WHERE comments IS NOT NULL;
SELECT COUNT(*) FROM orders;
SELECT COUNT(*) FROM orders WHERE shippedDate BETWEEN '2021-01-01' AND '2021-12-31';
SELECT COUNT(*) FROM orders WHERE comments IS NOT NULL;
/** There are 283 orders in total. In 2021 there were 110, in 2022 there were 173**/
SELECT COUNT(*) FROM orders WHERE status = 'Shipped' AND shippedDate BETWEEN '2021-01-01' AND '2021-12-31';
SELECT COUNT(*) FROM orders WHERE status = 'Shipped' AND shippedDate BETWEEN '2022-01-01' AND '2022-12-31';
/**--------------------------------------------------------------------------------------------------------------**/
/** In 2021, there have been 108 shipped orders. In 2022 there have been 145 shipped orders**/
SELECT COUNT(*) FROM orders WHERE status = 'Cancelled' AND shippedDate BETWEEN '2021-01-01' AND '2021-12-31';
SELECT COUNT(*) FROM orders WHERE status = 'Cancelled' AND shippedDate BETWEEN '2022-01-01' AND '2022-12-31';
/**--------------------------------------------------------------------------------------------------------------**/
SELECT COUNT(*) FROM orders WHERE status = 'On Hold' AND shippedDate BETWEEN '2021-01-01' AND '2021-12-31';
SELECT COUNT(*) FROM orders WHERE status = 'On Hold' AND shippedDate BETWEEN '2021-01-01' AND '2021-12-31';
/**--------------------------------------------------------------------------------------------------------------**/
SELECT COUNT(*) FROM orders WHERE status = 'Resolved' AND shippedDate BETWEEN '2021-01-01' AND '2021-12-31';
SELECT COUNT(*) FROM orders WHERE status = 'Resolved' AND shippedDate BETWEEN '2021-01-01' AND '2021-12-31';