2 我有两张桌子
一个日志。电子邮件:
EmailNum EmployeeID, Emailcontent, EmailReceivers ,is_read
1 1 , "sasa" , "sas@google.com" ,1
2 1 , "sasa" , "sas@google.com" ,0
3 2 , "sasa" , "sas@google.com" ,0
4 2 , "sasa" , "sas@google.com" ,0
5 2 , "sasa" , "sas@google.com" ,0
和Employees.user
id, FirstName, LastNAme
1 , "John" , "Brown"
2 , "Jack" , "James"
我想要的输出:
名字,姓氏,未读电子邮件数
John , Brown , 1
Jack , James ,3
我的尝试(但它没有返回所需输出的第一行,即“John , Brown ,1”):
SELECT
*, count(EmployeeID) as NumEmails
FROM
logs.emails a
inner join
Employees.user b on a.EmployeeID=b.id
group by
EmployeeID
having
a.is_read='0'
感谢您的帮助