nijian Posted September 25, 2019 Share Posted September 25, 2019 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 More sharing options...
shaili_shah Posted January 23, 2020 Share Posted January 23, 2020 I think this query will give you the desired result : select cno , MAX(pno) as pno from ono group by cno; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now