Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. ID Date Direction
  2. 1 2017-04-01 1
  3. 2 2017-04-01 1
  4. 3 2017-04-01 -1
  5. 4 2017-04-01 1
  6. 5 2017-04-01 -1
  7. 6 2017-04-01 1
  8. 7 2017-04-02 -1
  9. 8 2017-04-02 -1
  10. 9 2017-04-02 -1
  11. 10 2017-04-02 1
  12. 11 2017-04-02 -1
  13. 12 2017-04-03 -1
  14.  
  15. DATE positive negative
  16. 2017-04-01 4 2
  17. 2017-04-02 1 4
  18. 2017-04-03 0 1
  19.  
  20. SELECT DATE,
  21. CASE
  22. WHEN direction < 0 THEN 'negative'
  23. WHEN direction > 0 THEN 'positive'
  24. END AS updownType, count(*) AS updownCount
  25. FROM table WHERE DATE BETWEEN '2017-04-01' AND '2017-04-03'
  26. GROUP BY DATE, updownType
  27. ORDER BY DATE ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement