SQL - SELECT SUM joined with another table
I had always face a scenerio like this:
There are 2 tables
1 | user(id, first_name, last_name) |
Now I want to SUM all the quantity based on user, typically what I did is
1 | SELECT user_id, SUM(qty) as total |
But the problem is, I want the first_name and last_name as well. How to get this in one query?
I had found a solution here:
1 | SELECT id, first_name, last_name, total |