2 I have two tables
one logs.emails:
EmailNum EmployeeID, Emailcontent, EmailReceivers ,is_read
1 1 , "sasa" , "[email protected]" ,1
2 1 , "sasa" , "[email protected]" ,0
3 2 , "sasa" , "[email protected]" ,0
4 2 , "sasa" , "[email protected]" ,0
5 2 , "sasa" , "[email protected]" ,0
and Employees.user
id, FirstName, LastNAme
1 , "John" , "Brown"
2 , "Jack" , "James"
My desired Output:
FirstName, LastName, NumOfUnreadEmails
John , Brown , 1
Jack , James ,3
My attempt(But it does not return the irst row of desired output which is "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'
Your help is appreciated
*, COUNT(since you would have to group all columns. Are you just wanting * fromEmployees.user?