Bring values from different in a query

J

James O

I have asked a question similar to this once before allow me to clarify it.
Here is what the table looks like.There is more than 1 MIO value.

VendorCode Volume MIO
2515 1 NBCC

Ok The vendor codes range from 2000 to 9000. The count can be any number.
There are 7 different MIO's. NACC and NACW are the two that give me
trouble..... here is why. I pull a report showing these fields and I am
trying to accurately import into an access table. I have a Import table that
I put the initial data on. Then I append to the main table adding a date and
timestamp of time/date appended. There can be more than one of the same
vendor code. That is not a problem accept with NACC NACW. On a report that I
pull from this data I count the total number of times a vendor code appears
under one of the MIO's on a given date and a sum of the Volume for each
instance of that VendorCode under the same MIO. So I Import this...

VendorCode Volume MIO
2515 2 NBCC
2515 2 NBCC
2516 2 NACC
2516 2 NACC

And Output this on the report.

VendorCode CountOfVendor Volume MIO
2515 2 4 NBCC
2516 2 4 NACC

On a much larger scale of course. My problem is with NACC and NACW. I need
to add NACW volumes to NACC records of the same vendor codes. But NOT add the
NACW vendor codes to the CountofVendor. AND not have NACW on the report. So
remove NACW from the report but add its volume to the corresponding vendor
codes and not add NACW vendor codes to the CounfOfVendor. So what is better,
do this during the append process or using queries between the table and the
report. I am going to mess around with using multiple queries between the
table and report. I apologize for my previous post it was not detailed
enough. Thanks for all your help and have a great day!


James O'Donnell
 
K

KARL DEWEY

Try this --
SELECT Table27.VendorCode, Sum(IIf([MIO]="NACW",0,1)) AS [Count of Vendors],
Sum(Table27.Volume) AS SumOfVolume, IIf([MIO]="NACW","NACC",[MIO]) AS MIOs
FROM Table27
GROUP BY Table27.VendorCode, IIf([MIO]="NACW","NACC",[MIO]);
 
Top