MS-access query

Bala

Board Regular
Joined
Jun 10, 2003
Messages
92
Hi,

I want to count the number of vendors in a table. For example vendor 1 conmtains 10 records, vendor 2 contains 15 records and so on.

How do write a query for it. Pls. help. Thanks

-Bala
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Assuming that you want to know how many unique vendors you have in a table (let's assume Orders), ie Vendor A -- 10 records, Vendor B -- 15 records, vendor count -- 2, here is a way to do it using 2 queries.

qryGroupTheVendors:
Create a new query from the Orders table with the field [VendorID] inserted twice. In the toolbar, click the Sigma tool (I think the tooltip says Group or Totals). This will give you a new line, Totals, in the query grid.
In the first [VendorID] field, select Group By. In the second, select Count. Run the query -- you'll see something like

Vendor A 10
Vendor B 15
etc

Close and save the query.

qryUniqueVendors:
New query based on qryGroupTheVendors. Insert the first field from this query in the grid, click the Sigma button, select Count, and there you have it.

A bit round about, but no need for code. (And you may find some use for the first query elsewhere in the system...)
 
Upvote 0

Forum statistics

Threads
1,221,551
Messages
6,160,460
Members
451,648
Latest member
SuziMacca

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