Skip to content

Instantly share code, notes, and snippets.

@bunnywong
Last active August 29, 2015 14:19
Show Gist options
  • Save bunnywong/a158b1b1f5060627ddbd to your computer and use it in GitHub Desktop.
Save bunnywong/a158b1b1f5060627ddbd to your computer and use it in GitHub Desktop.
Lunch together calc
#Detail
SELECT username,(cost) FROM posts, users
WHERE
consumer_id = 2 &&
posts.payer_id = users.id &&
payer_id <> 2
#Summary
SELECT username,SUM(cost) FROM posts, users
WHERE
consumer_id = 2 &&
posts.payer_id = users.id &&
payer_id <> 2
GROUP BY
username
-----------
#Detail
SELECT username, (cost) FROM posts, users
WHERE
consumer_id <> 2 &&
posts.consumer_id = users.id &&
payer_id = 2
#Summary
SELECT username, SUM(cost) FROM posts, users
WHERE
consumer_id <> 2 &&
posts.consumer_id = users.id &&
payer_id = 2
GROUP BY
username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment