Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Distinct Keyword in Select statement

 
Mallika Kumar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm making a join involving 5 tables, all with primary and foreign keys. For example, if one table has a unique empno(for employee table),another table(vacation) has many values for that same empno depending on the number of vacations that empno has taken.The unique primary key for vacation is say vacationno. Now, when I make the join (which involves getting personal information etc), based on the empno, I get multiple rows with the same data in it for an empno with mutliple entries in vacation table. If I try to use distinct in my select statement,
I get an error saying :
ORA-00920: invalid relational operator
My question is, when I use distinct, does it hold good for only the first column immediately after it, or to all columns in the select statement ? And why am I getting the above error ? When I type the select statement without the distinct clause, it runs properly. With distinct, i get the error.
Is there a way to get the desired result, ie, only one row in vacation table for multiple empno values ? I want to use empno as my selective criteria.
Any suggestions will be very heplful.
Thanks.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could we see the statement? A group by might work.
 
Raja Shekhar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mallika...
U got The Master Table...and Detail Table....
to get The Personal Info U r making..JOIN...rite..
just try..
Select e.empno,e.name
from emp e,vac v
where e.empno=v.empno
and let me know...
chio
Raj
 
Mallika Kumar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks a lot Thomas and Raja. Wierd, but when I tried the query in sql+, it did not work. But when I tried it out with my java class, it worked !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic