我正在做一個查詢,但並不是所有的用戶名只顯示與值。請檢查我的代碼,看看我的where
子句中腳麻SQL沒有返回值,它是NULL
Select a.Owner_Id,
a.Creator_Id,
b.Name as KPI,
B.Record_Type,
B.Resource_Id,
C.Display_Name,
Count(a.owner_id) AS MAX,
case when a.owner_Id is null then c.Display_name else 0 end
from amgr_appointments_tbl A
left join AMGR_Resources B on A.Owner_Id = b.Resource_Id
left join ADMN_User_Details AS C ON A.Creator_Id = C.User_Id
where b.Resource_Id in('ROE534B758E', 'R0E42A431B5', 'R0E42A4BB3F','R0E42A3E514','R0E42A44D19', 'R0E42A37FBB')
and b.Record_Type = 3
and a.Creator_Id In('AMCKENZIE','ASARAK','CWEIMANN', 'EWOOLDRIDGE', 'GHAVENGA', 'JSTAPELBERG','WILLEMB', 'YRHODA', 'JMALAN')
and A.App_Date BETWEEN '20160201' and '20160331'
Group by a.Owner_Id, a.Creator_Id, b.Name, B.Record_Type, B.Resource_Id, c.Display_Name
抱歉搞砸了這個問題 – Stix
您的查詢以'amgr_appointments_tbl'開頭。對於這個tbl,你可以用'LEFT JOIN'連接另外兩個表。這將顯示約會沒有用戶,但沒有約會的用戶...如果你想看到所有用戶,從那裏開始,或嘗試'RIGHT JOIN' – Shnugo