Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID Date Direction
- 1 2017-04-01 1
- 2 2017-04-01 1
- 3 2017-04-01 -1
- 4 2017-04-01 1
- 5 2017-04-01 -1
- 6 2017-04-01 1
- 7 2017-04-02 -1
- 8 2017-04-02 -1
- 9 2017-04-02 -1
- 10 2017-04-02 1
- 11 2017-04-02 -1
- 12 2017-04-03 -1
- DATE positive negative
- 2017-04-01 4 2
- 2017-04-02 1 4
- 2017-04-03 0 1
- SELECT DATE,
- CASE
- WHEN direction < 0 THEN 'negative'
- WHEN direction > 0 THEN 'positive'
- END AS updownType, count(*) AS updownCount
- FROM table WHERE DATE BETWEEN '2017-04-01' AND '2017-04-03'
- GROUP BY DATE, updownType
- ORDER BY DATE ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement