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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Help

Status
Not open for further replies.

MickDub

Programmer
Apr 19, 2006
9
IE
i have follwoing table showing part number M1 with 5 entries
PONum PartNum
5331 M1
5331 M1
5332 M1
5332 M1
5332 M1

what i need help with is to be able to qrite a query that return that even though there are 5 entries for M1 that it is only on two seperate PoNum's

Part Num PoNum Count
M1 2 '(showings it is on 2 Different PoNumbers)
 
Try

select temp1.partnum, count(temp1.PONum) as PoNumbCount from [select distinct partnum, ponum from tablename] as temp1 group by temp1.partnum

Or, use two queries

Query1
select distinct partnum, ponum from tablename

Query2
select partnum, count(PONum) as PoNumbCount from query1 group by partnum

-Coco

[auto]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top