Jump to content

SQL Select Max Count Distinct and Distinct


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 post
Share on other sites
  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...