September 5, 2010 at 4:54 pm
Hi SQL SERVER Good Guys, 😛
I need your help. Please help me.
I have been asked to create a SQL STRING to determine overall the Total number of records from different Data Tables
My coding list below instead of the SUM of all the column as one column but it's not working instead it's generate 4 columns of result
supp shipcity ShpCity CustCity
12 6 6 16
SELECT DISTINCT
COUNT(TblSuppliers.City) AS Supp, COUNT(TblInvoices.ShipCity) AS ShipCity, COUNT(TblInvoices.City) AS ShpCity, COUNT(TblCustomers.City) AS CustCity
FROM TblCityRef RIGHT OUTER JOIN
TblSuppliers ON TblCityRef.City = TblSuppliers.City RIGHT OUTER JOIN
TblInvoices ON TblCityRef.City = TblInvoices.City RIGHT OUTER JOIN
TblCustomers ON TblCityRef.City = TblCustomers.City
WHERE (TblCityRef.City = 'Berlin')
September 6, 2010 at 11:35 pm
you can do this by few ways.
SELECT DISTINCT
(COUNT(TblSuppliers.City)+ COUNT(TblInvoices.ShipCity) + COUNT(TblInvoices.City)+ COUNT(TblCustomers.City)) as total
FROM TblCityRef RIGHT OUTER JOIN
TblSuppliers ON TblCityRef.City = TblSuppliers.City RIGHT OUTER JOIN
TblInvoices ON TblCityRef.City = TblInvoices.City RIGHT OUTER JOIN
TblCustomers ON TblCityRef.City = TblCustomers.City
WHERE (TblCityRef.City = 'Berlin')
[font="Verdana"]Regards
Kumar Harsh[/font]
September 7, 2010 at 12:46 am
Hi Kumar Harsh
Thank you very much for the sample SQL STRING. 😛 😛
It works vey well and you are awesome and generous in sharing and helping. 🙂 🙂
Have a Good Day.
Cheers.
Lennie
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply