Guest User

Untitled

a guest
Oct 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. SELECT table1.timestamp::DATE, table2.segment, COUNT(table1.timestamp::DATE) as count, ABS(SUM(table1.amount)) as sum, table3.category, table3.text
  2.  
  3. FROM table1 LEFT JOIN table3 ON table1.id = table3.id LEFT JOIN table2 ON table1.hash = table2.hash
  4.  
  5. WHERE table1.time::DATE >= '2015-01-01' AND table1.time::DATE < '2015-02-01' AND table2.segment IN (1,2)
  6.  
  7. GROUP BY (table1.time::DATE, table2.segment, table3.category, table3.text) ORDER BY table1.timestamp::DATE, sum DESC;
Add Comment
Please, Sign In to add comment