-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDates.sq;
52 lines (40 loc) · 1.42 KB
/
Dates.sq;
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
52
/*
Find the sales in terms of total dollars for all orders in each year,
ordered from greatest to least. Do you notice any trends in the yearly sales totals?
Which month did Parch & Posey have the greatest sales in terms of total
dollars? Are all months evenly represented by the dataset?
Which year did Parch & Posey have the greatest sales in terms of total
number of orders? Are all years evenly represented by the dataset?
Which month did Parch & Posey have the greatest sales in terms of total
number of orders? Are all months evenly represented by the dataset?
In which month of which year did Walmart spend the most on gloss paper in
terms of dollars?
*/
Select Date_Part('year', occurred_at),sum(total)
from modeanalytics.parch_and_posey_orders
Group by 1
order by 2;
Select Date_part('month', occurred_at),sum(total_amt_usd)
from modeanalytics.parch_and_posey_orders
Group by 1
order by 2 desc
limit 1;
Select Date_Part('year', occurred_at),sum(total)
from modeanalytics.parch_and_posey_orders
Group by 1
order by 2 desc
limit 1;
Select Date_Part('month', occurred_at),Count(total) as num_orders
from modeanalytics.parch_and_posey_orders
Group by 1
order by 2 desc;
Select Date_Trunc('month', o.occured_at), sum( o.gloss_amt_usd),
a.name account_name
from modeanalytics.parch_and_posey_orders o
Join
modeanalytics.parch_and_posey_account a
on a.id = o.account_id
Group by 1,3
Having a.name = 'Walmart'
Order by 2 desc
limit 10;