Skip to content

Instantly share code, notes, and snippets.

@Wqrld
Created March 3, 2023 13:04
Show Gist options
  • Save Wqrld/4ea5a789eafd10fcff2927977f96c426 to your computer and use it in GitHub Desktop.
Save Wqrld/4ea5a789eafd10fcff2927977f96c426 to your computer and use it in GitHub Desktop.
select sum(amount) as sum,username from Payments
JOIN Users on Users.id = Payments.client
where state = 'paid' OR state = 'approved'
group by username
order by sum desc
limit 50;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment