Subject | Valid reasons for sorting on a column one doesn't select? |
---|---|
Author | plinehan |
Post date | 2005-08-13T16:40:51Z |
This works in FB
SELECT DISTINCT(First_Name)
FROM Employee
ORDER BY Last_Name
but this doesn't in Oracle
SELECT DISTINCT(Ename)
FROM Emp
ORDER BY Sal
------------------
with the error
ERROR at line 3:
ORA-01791: not a SELECTed expression
------------------
I thought that I was missing something extremely
simple in Oracle, so I posted the info there, only
to be told that
--------------------------
It is pretty useless to order on sal when
you don't display the sal. Oracle agrees with me.
Oracle != Sqlserver and whatever toy products are
available .
-----------------------------
Can anyone give me a few valid reasons why
one might want to sort on a field that
one doesn't select?
Paul...
SELECT DISTINCT(First_Name)
FROM Employee
ORDER BY Last_Name
but this doesn't in Oracle
SELECT DISTINCT(Ename)
FROM Emp
ORDER BY Sal
------------------
with the error
ERROR at line 3:
ORA-01791: not a SELECTed expression
------------------
I thought that I was missing something extremely
simple in Oracle, so I posted the info there, only
to be told that
--------------------------
It is pretty useless to order on sal when
you don't display the sal. Oracle agrees with me.
Oracle != Sqlserver and whatever toy products are
available .
-----------------------------
Can anyone give me a few valid reasons why
one might want to sort on a field that
one doesn't select?
Paul...