2021年1月26日星期二

How can I get a subtotal for each t.title?

I run this query

SELECT DISTINCT t.title,  t.role      FROM titles t, employees e    WHERE e.employee_title=t.title   

and my result is:

title role
developer researcher
tester supervision sales support

But what I really want is include the number of each title and the total wages of that title. So I tried this SELECT DISTINCT t.title, t.role, COUNT(e.employee_title), SUM(w2_wages) FROM titles t, employees e WHERE e.employee_title=t.title

But this yields just this:

 title        role      Count    sum  developer   researcher  20      1057267   

What I really want is this line for EACH title.

How do I modify this code?

https://stackoverflow.com/questions/65912373/how-can-i-get-a-subtotal-for-each-t-title January 27, 2021 at 11:07AM

没有评论:

发表评论