-
Notifications
You must be signed in to change notification settings - Fork 439
/
Expenses.sql
36 lines (36 loc) · 1018 Bytes
/
Expenses.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
CREATE TABLE Expenses AS
SELECT
CASE type
WHEN "INV" THEN "Invest"
WHEN "LOV" THEN "Family"
WHEN "EDU" THEN "Education"
WHEN "BOO" THEN "Book"
WHEN "STA" THEN "Stationary"
WHEN "PEN" THEN "Pen"
WHEN "FOO" THEN "Food"
WHEN "CLO" THEN "Clothes"
WHEN "SAR" THEN "Sartorial"
WHEN "SHO" THEN "Shoes"
WHEN "ACC" THEN "Accessory"
WHEN "HYG" THEN "Health"
WHEN "FUR" THEN "Home"
WHEN "ELE" THEN "Electronics"
WHEN "COM" THEN "Communication"
WHEN "SOC" THEN "Social"
WHEN "TRA" THEN "Transportation"
WHEN "HOU" THEN "Housing"
WHEN "AUT" THEN "Automobile"
WHEN "ENT" THEN "Entertainment"
WHEN "SOF" THEN "Software"
WHEN "LEG" THEN "Legal"
WHEN "TAX" THEN "Tax"
WHEN "INS" THEN "Insurance"
WHEN "MIS" THEN "Miscellany"
ELSE type
END AS "category"
,ROUND(abs(priceCNY) / 6.6, 2) AS "cost"
,time
FROM items
WHERE userID LIKE "shaw%"
AND deleted = 0
AND time BETWEEN '2018-01-01 00:00:00' AND '2019-01-01 00:00:00';