Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Issue... Oh Boy! MS Access....give me a break!

Status
Not open for further replies.

amacfarl

Programmer
Jun 23, 2003
8
0
0
DE
Folks,

I have the following table in MS Access:

TABLE: ProductsForSales
Seller
Category
IsSold

QUESTION 1: I know that you cannot use COUNT(DISTINCT xx) in MS Access. However how can I run a query returning the number of Categories the Seller is currently Selling in.. I.e. In Oracle I would do:

SELECT Seller, COUNT(DISTINCT Category)
FROM ProductsForSale


QUESTION 2: If I want to retreive the number of products sold and the number not sold by customer, I would run the following queries:

SELECT Seller, COUNT(*) WHERE IsSold = Y
AND
SELECT Seller, COUNT(*) WHERE IsSold = N

Is there any way of combining both these queries into one?

I would greatly appreciate any help as I am going round and round in circles and ending up nowhere!!

Many thanks
Angus

 
SELECT Seller, Category, count(*) as cnt
FROM ProductsForSale
Group by Seller, Category

SELECT Seller, sum(iif(IsSold = Y,1,0) as Ysold,
sum(iif(IsSold = N,1,0) as Nsold
From ProductsForSale
Group by Seller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top