For the PO table layout below:
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
PoNum Part 53831 M1 53831 M1 53832 M1 53833 M2 53831 M2
I need to return that M1 is on two seperate PoNums and M2 is on two PoNums. Any help is greatly appreciated.
"Separate" PoNums can be counted using the DISTINCT keyword in the COUNT function:
select Part , count(distinct PoNum) as PoNums from PO group by Part
Easy when you see it, eh?
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback.continue reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback.continue reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.