This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "SQL Doubt" Watch "SQL Doubt" New topic
Author

SQL Doubt

Sirisha Reddy
Ranch Hand

Joined: Jun 09, 2003
Posts: 75
THIS CODE WORKS-
select distinct emp.deptno, dname from emp,dept where dept.deptno=emp.deptno;
BUT THIS WOULDNT
select emp.deptno, distinct dname from emp,dept where dept.deptno=emp.deptno;
ANY INSIGHTS??
Thanks.


SCJP 1.4
Dorothy Finkel-Laverty
Ranch Hand

Joined: Nov 24, 2001
Posts: 51
It's an SQL thing - the word DISTINCT refers to the entire row, not just one column. As such, it belongs, syntactically, before the list of all columns.
Sirisha Reddy
Ranch Hand

Joined: Jun 09, 2003
Posts: 75
got it. distinct is single row function.
thanks buddy
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Mr. Multeon:

Howdidly ho neighbo[u]r, and welcome to the Ranch! We hope you’ll enjoy pounding back pints of java help on a regular basis. However, we do have one piddly diddly little rule around these parts. Please change your display name to one that satisfies our piddly diddly little rule( naming policy - The skinny of the policy: just use a real firstname, followed by a space and a real lastname ). That's all! Thanks again and we hope to see you ordering up pints of java help on a regular basis!
Jamie
Sirisha Reddy
Ranch Hand

Joined: Jun 09, 2003
Posts: 75
I did.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: SQL Doubt
 
Similar Threads
Group By Expr
Finding an average as part of a join (Ora 11)
prepared statements in PL/SQL
Get Maximum sal from emp table
Is the answer correct?