aspose file tools*
The moose likes JDBC and the fly likes SQL SELECT DISTINCT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL SELECT DISTINCT" Watch "SQL SELECT DISTINCT" New topic
Author

SQL SELECT DISTINCT

Adam Shirley
Greenhorn

Joined: Jan 31, 2008
Posts: 1
I have a servlet that accesses a datafile, performs a query, and retrieves the information from it. Here is what the select string currently looks like:

SELECT tdydno, tdload, tltype, tlacctno, taname, tlcymd, tlamount, tdstatus, tdsrn

I want to perform a SELECT DISTINCT on tdload. That is, I do not want the same load number displayed twice. It's okay if everything else is displayed twice, just not tdload. Using the keyword DISTINCT here automatically tries to apply it to all of the other words, I think. Is there a way around this?
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
I believe you are looking for Group By ?
Kevin Smither
Ranch Hand

Joined: Oct 22, 2007
Posts: 30
Yes, you can use GROUP BY but in this case you have to supply aggregate functions for the other columns
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL SELECT DISTINCT