Hi all!
I've tried everything, but cannot get my query right. Believe I should
use rollup or cube to solve this, but don't know how. Hope you can
help.
This is the issue:
2 tables:
Organizations:
Org_Id
Org_Name
Org_Phone
Org_Fax
Contacts:
Con_Id
Org_Id
Con_Name
Con_Phone
Con_Cellular
My query should return:
Org_Id | Org_Name | Org_Phone | Con_Id | Con_Name | Con_Phone | Number
of Cons for Org
Actually I almost got it right with this one:
SELECT dbo.Organizations.Org_Name, dbo.Contacts.Con_Name,
count(dbo.Contacts.Org_Id) as Total
FROM dbo.Contacts
RIGHT OUTER JOIN dbo.Organizations ON dbo.Contacts.Con_Id =
dbo.Organizations.Org_Id
GROUP BY dbo.Organizations.Org_Name, dbo.Contacts.Con_Name WITH ROLLUP
ORDER BY dbo.Organizations.Org_Name
but when I try to add more fields to the query everything goes
wrong...
Thank you for you help!
Best regards
Tore Fremmersvik