Guest User

Untitled

a guest
Jan 20th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. mysql> select * from view_command_OPEN_CLOSED_tally limit 5;
  2. +---------------------+-------------------------+-----------------------+---------------------+-------------------+----------------------+--------------------+
  3. | created | total_accounts_credited | total_amount_credited | total_open_credited | total_amount_open | total_closed_credited| total_amount_closed|
  4. +---------------------+-------------------------+-----------------------+---------------------+-------------------+----------------------+--------------------+
  5. | 2019-01-19 00:00:00 | 18175 | 3173.68 | 16953 | 7063.68 | 1222 | 110.00 |
  6. | 2019-01-12 00:00:00 | 18135 | 4768.43 | 17053 | 9358.43 | 1082 | 410.00 |
  7. | 2019-01-10 09:00:27 | 80 | 1497.75 | 80 | 1497.75 | 0 | 0.00 |
  8. | 2019-01-09 09:20:55 | 51 | 933.50 | 50 | 915.75 | 1 | 17.75 |
  9. | 2019-01-08 16:45:14 | 10 | 187.50 | 10 | 187.50 | 0 | 0.00 |
  10. +---------------------+-------------------------+-----------------------+---------------------+-------------------+----------------------+--------------------+
  11.  
  12. mysql> SELECT vtally.created,
  13. -> vtally.total_accounts_credited,
  14. -> vtally2.total_accounts_credited `previous`,
  15. -> vtally.total_open_credited ,
  16. -> vtally2.total_open_credited `previous`,
  17. -> vtally.total_closed_credited,
  18. -> vtally2.total_closed_credited`previous`
  19. -> FROM view_command_OPEN_CLOSED_tally vtally
  20. -> LEFT JOIN view_command_OPEN_CLOSED_tally vtally2
  21. -> ON vtally.created = vtally2.created - INTERVAL 7 DAY
  22. -> GROUP BY
  23. -> DATE(vtally.created)
  24. -> ORDER BY vtally.created DESC LIMIT 2;
  25. +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
  26. | created | total_accounts_credited | previous | total_open_credited | previous | total_closed_credited | previous |
  27. +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
  28. | 2019-01-19 00:00:00 | 8175 | NULL | 6953 | NULL | 222 | NULL |
  29. | 2019-01-12 00:00:00 | 8135 | 8175 | 7053 | 6953 | 082 | 1222 |
  30. +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
  31.  
  32. +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
  33. | created | total_accounts_credited | previous | total_open_credited | previous | total_closed_credited | previous |
  34. +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
  35. | 2019-01-19 00:00:00 | 8175 | 8135 | 6953 | 7053 | 222 | 082 |
  36. | 2019-01-12 00:00:00 | 8135 | 8175 | 7053 | 6953 | 082 | 1222 |
  37. +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
Add Comment
Please, Sign In to add comment