Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Baffling SQL failure in Oracle - anyone explain?
In response to a post on comp.databases I did a bit of testing and found a very strange result.
This works in Firebird (and something similar apparently works in MySQL)
SELECT DISTINCT(First_Name)
FROM Employee
ORDER BY Last_Name
There is a sample db Employee, somewhat similar to Scott.Emp.
However these both fail in Oracle
SELECT DISTINCT(Ename)
FROM Emp
ORDER BY Sal
or even ORDER BY Emp.Sal
with the error
ERROR at line 3:
ORA-01791: not a SELECTed expression
Now, I can't for the life of me figure out why this query is failing in Oracle - I think that it's perfectly reasonable to sort on a column that one isn't selecting on.
This is so simple that I'm asking myself if I've overlooked something really *_really_* obvious.
Paul...
-- plinehan __at__ yahoo __dot__ __com__ XP Pro, SP 2, Oracle, 9.2.0.1.0 (Enterprise Ed.) Interbase 6.0.1.0; When asking database related questions, please give other posters some clues, like operating system, version of db being used and DDL. The exact text and/or number of error messages is useful (!= "it didn't work!"). Thanks. Furthermore, as a courtesy to those who spend time analysing and attempting to help, please do not top post.Received on Sat Aug 13 2005 - 10:14:49 CDT
![]() |
![]() |