This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes to get the most repeated column name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "to get the most repeated column name" Watch "to get the most repeated column name" New topic

to get the most repeated column name

pavani potnuru

Joined: Nov 04, 2007
Posts: 11
I have lot of products ordered by the user.Some of them are repeated.
How to get the most 5 frequently ordered products from the column named Product.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32317

This query gives you the number of each distinct products. You want to add a clause to get the first 5 rows. This part varies by database.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
subject: to get the most repeated column name
It's not a secret anymore!