Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE new_table as
- SELECT id AS first_id , deposit_amount AS `first`,
- id + 1 AS second_id,
- (
- SELECT deposit_amount
- FROM wizzard_deposits
- WHERE id = second_id
- ) AS `second`
- , (
- SELECT ((SELECT deposit_amount
- FROM wizzard_deposits
- WHERE id = first_id) - (SELECT deposit_amount
- FROM wizzard_deposits
- WHERE id = second_id))
- ) AS diff
- from wizzard_deposits
- GROUP BY id
- HAVING `second` IS NOT NULL;
- SELECT sum(diff)
- FROM new_table;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement