sql - Can I combine my two SQLite SELECT statements into one? -
I have a SQLite table called posts
An example is given below. I would like to calculate monthly income and expenditure.
accId Date Text Balance ---------- ---------- ------- ----------- ------ ---------- ---------- 2008-03-25 Ex1-64.9 3747.56 1 2008- 03-25 Shop2-91.85 3655.71 1 2008-03 -26 Benny's -100.0 3555.71
I have this question for income:
SELECT SUBSTR (date, 0, 7) "month", total (quantity) "income" posts From where the amount> 0 month order date by group;
This works fine:
Now I need the expenses and I can repeat the first statement with the condition of its cause Amount & lt; 0
, but I'm thinking that a query is a great way to get both income and expenditure?
try something like this
Case "(when a & lt; 0 is again another zero) select substrold ( Date, 0,7) "Month", total (in case when a> 0 then another zero) "Income"
Comments
Post a Comment