SQL Query Question

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
The following query returns 11,869 records, but the table "tprod" has 14,752. Shouldn't the Right Join force the query to return 14,752 rows, even if 2,883 of them have no matching data in tURMSReport?

Code:
SELECT T1.Product, T1.Business_Unit, T1.ProductDesc, T1.NDC11, T1.State, T1.State_Category, SUM(T1.iMANY_FFS_Units) AS iMANYFFSUnits, SUM(T1.iMANY_MCO_Units) AS iMANYMCOUnits, 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;
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top