This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL Doubt

 
Sirisha Reddy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dorothy Finkel-Laverty
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it. distinct is single row function.
thanks buddy
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!