The following query returns 26,318 rows, even though the table tProd has 27,018 rows:
I figure it's because of the GROUP BY clause. Is there a way to force the query to show all 27,018 rows from tProd even after the GROUP BY is executed?
Code:
SELECT T1.Product, T1.Business_Unit, T1.ProductDesc, T1.NDC11, T1.State, T1.State_Category, SUM(T1.iMANY_Units) AS iMANYUnits, SUM(T1.ffs_Units) AS FFSUnits, SUM(T1.mco_Units) AS MCOUnits
FROM (tURMSReport T1
RIGHT OUTER JOIN
tProd T2
ON T1.NDC11=T2.NDC11 AND T1.State=T2.State)
WHERE T1.Quarter='Q1_2008'
GROUP BY T1.Product, T1.Business_Unit, T1.ProductDesc, T1.NDC11, T1.State, T1.State_Category
ORDER BY T1.Product, T1.State, T1.NDC11;
I figure it's because of the GROUP BY clause. Is there a way to force the query to show all 27,018 rows from tProd even after the GROUP BY is executed?