Jump to content

SQL Select Max Count Distinct and Distinct


nijian

Recommended Posts

Hi there,

I am working on a problem that goes as follows.

Two tables: order1 and odetails

Tables have one common attribute: ono (order number)

Two main attributes: cno (customer number) and pno (part number)

I want to select the maximum reoccurring part number associated to a distinct customer number.

For example: cno 1001 has 5 pno values, 3 are 3003 and 2 are 2002

I want to return one distinct cno 1001 and the max pno count, so 3003 in this example.

cno          pno

1001        3003

 

I hope this makes sense. Thank you for any and all effort!

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...