我正在尝试编写一个SQL查询来显示每个用户的某些值的输入量。如何显示给定人的所有行的总和
下面是我在MySQL中使用的表格。这些表不包含任何FK,仅包含用于性能目的的PK。
表LIST_DETAILS:
表USERS:
表配置:
下面是我尝试过的SQL查询。我遇到的问题是它只显示一个用户,而不是我期望的250个用户。
select job_name, concat(fname,' ',lname),
sum(disposition_category = 'Attempts') as Attempts,
sum(disposition_category = 'RPC') as RPC,
sum(disposition_category = 'Contacts') as Contacts,
sum(disposition_category = 'Voted') as Voted,
sum(disposition_category = 'RPC and Voted') as 'RPC and Voted',
sum(disposition_category = 'Other') as Other,
sum(disposition_category = 'Directory Assistance') as 'Directory Assistance'
from list_details ld
join users u ON u.id = ld.id
join dispositions d ON d.id = u.id
where security_level = 1;
这是我想看到的输出,但它只显示一个用户,当我需要看到250显示。
| job_name | concat(fname,' ',lname) | Attempts | RPC | Contacts | Voted | RPC and Voted | Other | Directory Assistance |
| SPDR-lower-range8-8-14 | Rosybel Abreu | 11 | 10 | 7 | 0 | 0 | 9 | 1 |
任何人都可以帮助我纠正我的错误吗?
我正确地认为'11'尝试是针对所有员工的,而不仅仅是上面显示的那个? – AdamMc331 2014-11-14 16:40:19