One More Access SQL Question

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
The following query returns 26,318 rows, even though the table tProd has 27,018 rows:

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?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I am kind of confused. Why are you GROUPING at all if you don't want the results grouped?

How many records do you get if you run this query?
Code:
SELECT NDC11, State
FROM tProd
GROUP BY NDC11, State;

If this issue is you need to group the records from tURMSReport, then do that first, grouping just that table in its own query or a subquery before joining to tProd so that tProd is not part of the Aggregate Query.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,233
Members
452,898
Latest member
Capolavoro009

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