-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.txt
33 lines (27 loc) · 666 Bytes
/
2.txt
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
SELECT City,
SUM(Amount) AS TotalExpenditure
FROM credit_cards
GROUP BY City
ORDER BY TotalExpenditure DESC
LIMIT 1;
-- ii) Lowest total expenditure
SELECT City,
SUM(Amount) AS TotalExpenditure
FROM credit_cards
GROUP BY City
ORDER BY TotalExpenditure ASC
LIMIT 1;
-- iii) Highest average expenditure
SELECT City,
AVG(Amount) AS AverageExpenditure
FROM credit_cards
GROUP BY City
ORDER BY AverageExpenditure DESC
LIMIT 1;
-- iv) Lowest average expenditure
SELECT City,
AVG(Amount) AS AverageExpenditure
FROM credit_cards
GROUP BY City
ORDER BY AverageExpenditure ASC
LIMIT 1;