This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes Seeking help on a complex SQL I reckon, wish get a simple one from answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Seeking help on a complex SQL I reckon, wish get a simple one from answer" Watch "Seeking help on a complex SQL I reckon, wish get a simple one from answer" New topic
Author

Seeking help on a complex SQL I reckon, wish get a simple one from answer

Steven Jiang
Greenhorn

Joined: Mar 01, 2008
Posts: 22
Hi All

Another sql to ask here. we have a table
File(name ,date, file_size).
anyone has simple query to list name of file where the related size is not 0

let me give some sample data.
name date size
a 1/1/2001 0
a 2/1/2002 2
a 3/3/2003 0
b 1/1/2000 3
b 2/2/2001 4

If I run the query, it should list "b" only as "a" has two related size = 0.

Thanks in advance.

I know a complex query already, just want a simple one.
my query is


I gotta keep learning...
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


select distinct(name) from File where size!=0

more faster
select distinct(name) from File where size > 0
Steven Jiang
Greenhorn

Joined: Mar 01, 2008
Posts: 22
Balu Sadhasivam wrote:
select distinct(name) from File where size!=0

more faster
select distinct(name) from File where size > 0


thanks for that, but your answer is not right, if you run it against the table I created, you will get "a", "b", but "a" is related two records with '0' in size field.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I can't help you much, but I modified your original query little bit.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Steven Jiang wrote:[you will get "a", "b", but "a" is related two records with '0' in size field.


oh yeah.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seeking help on a complex SQL I reckon, wish get a simple one from answer