我正在嘗試編寫一個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