Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> select * from view_command_OPEN_CLOSED_tally limit 5;
- +---------------------+-------------------------+-----------------------+---------------------+-------------------+----------------------+--------------------+
- | created | total_accounts_credited | total_amount_credited | total_open_credited | total_amount_open | total_closed_credited| total_amount_closed|
- +---------------------+-------------------------+-----------------------+---------------------+-------------------+----------------------+--------------------+
- | 2019-01-19 00:00:00 | 18175 | 3173.68 | 16953 | 7063.68 | 1222 | 110.00 |
- | 2019-01-12 00:00:00 | 18135 | 4768.43 | 17053 | 9358.43 | 1082 | 410.00 |
- | 2019-01-10 09:00:27 | 80 | 1497.75 | 80 | 1497.75 | 0 | 0.00 |
- | 2019-01-09 09:20:55 | 51 | 933.50 | 50 | 915.75 | 1 | 17.75 |
- | 2019-01-08 16:45:14 | 10 | 187.50 | 10 | 187.50 | 0 | 0.00 |
- +---------------------+-------------------------+-----------------------+---------------------+-------------------+----------------------+--------------------+
- mysql> SELECT vtally.created,
- -> vtally.total_accounts_credited,
- -> vtally2.total_accounts_credited `previous`,
- -> vtally.total_open_credited ,
- -> vtally2.total_open_credited `previous`,
- -> vtally.total_closed_credited,
- -> vtally2.total_closed_credited`previous`
- -> FROM view_command_OPEN_CLOSED_tally vtally
- -> LEFT JOIN view_command_OPEN_CLOSED_tally vtally2
- -> ON vtally.created = vtally2.created - INTERVAL 7 DAY
- -> GROUP BY
- -> DATE(vtally.created)
- -> ORDER BY vtally.created DESC LIMIT 2;
- +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
- | created | total_accounts_credited | previous | total_open_credited | previous | total_closed_credited | previous |
- +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
- | 2019-01-19 00:00:00 | 8175 | NULL | 6953 | NULL | 222 | NULL |
- | 2019-01-12 00:00:00 | 8135 | 8175 | 7053 | 6953 | 082 | 1222 |
- +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
- +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
- | created | total_accounts_credited | previous | total_open_credited | previous | total_closed_credited | previous |
- +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
- | 2019-01-19 00:00:00 | 8175 | 8135 | 6953 | 7053 | 222 | 082 |
- | 2019-01-12 00:00:00 | 8135 | 8175 | 7053 | 6953 | 082 | 1222 |
- +---------------------+-------------------------+----------+---------------------+----------+----------------------+----------+
Add Comment
Please, Sign In to add comment