Q: SQL output order by keys possible?
Date: 1996/10/08
Message-ID: <f91-gal.844803653_at_nada.kth.se>#1/1
I've run into this snag. Having a table, is there any way to sort the output in anything but ascending/descending order?
Say you've got
select EMP,SALAR from ALL_EMPS
where SALAR <= 10000
order by DEPT
where EMP,SALAR and DEPT are all columns in the ALL_EMPS table. This will group together all the empolyees in all departments before showing the answer.
But what what I'd really like to do is to output a given department
first, something along the lines of
select EMP,SALAR from ALL_EMPS
order by DEPT where DEPT like 'PR' first
This doesn't work of course. Is there any way to do this? The best I can come up with on my own are two queries like this:
select EMP,SALAR from ALL_EMPS
where SALAR <= 10000
and DEPT like 'PR'
select EMP,SALAR from ALL_EMPS
where SALAR <= 10000
and DEPT NOT like 'PR'
However, I don't really like having two queries. Am I missing something terribly obvious here?
TIA,
/Göran
Received on Tue Oct 08 1996 - 00:00:00 CEST