This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman 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 Elasticsearch in Action this week in the Big Data 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: 31577

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
I agree. Here's the link:
subject: to get the most repeated column name