Annoying Access Syntax Error

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
The following query is giving me the error message, "You tried to execute a query that does not include the specified expression 'iMANY_Units' as part of an aggregate function." I can't figure out why, because my query DOES contain that expression. Can someone tell me what I'm missing?

Code:
SELECT ndc.Product,bus.Business_Unit,ndc.ProductDesc,ndc.NDC11,uts.State,GroupIDs.GroupName AS State_Category,uts.Quarter,uts.iMYUnits AS iMANY_Units,uts.ffsUnits AS FFS_Units,uts.mcoUnits AS MCO_Units
   FROM
(
(
(
(
((SELECT Customer AS State, NDC11, Units AS iMYUnits, 0 AS ffsUnits, 0 AS mcoUnits, Quarter FROM per_state_per_ndc11_iMY
UNION ALL
SELECT State, NDC11, 0  AS iMYUnits,Units AS ffsUnits, 0 AS mcoUnits, Quarter FROM IMS_FFS
UNION ALL
SELECT State, NDC11, 0  AS iMYUnits,0 AS ffsUnits, Units, Quarter as mcoUnits FROM IMS_MCO) AS uts)
LEFT JOIN NDC11_Dictionary AS ndc ON uts.NDC11=ndc.NDC11)
   LEFT JOIN Customer_Groups AS cg ON uts.State=cg.Customer)
   LEFT JOIN GroupIDs ON GroupIDs.GroupID=cg.Group)
   LEFT JOIN NDC11_BU_XREF AS bux ON uts.NDC11=bux.NDC11)
   LEFT JOIN Business_Units AS bus ON bux.BUID=bus.ID
GROUP BY Product,Business_Unit,ndc.NDC11,ProductDesc,State,GroupName,Quarter, iMANY_Units, ffs_Units, mco_Units;
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
In the Group By, replace
iMANY_Units
with
uts.iMYUnits

You can't use the alias in the Group By clause.

Denis
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,790
Members
452,942
Latest member
VijayNewtoExcel

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