Home » SQL & PL/SQL » SQL & PL/SQL » order problem
order problem [message #2654] Sun, 04 August 2002 12:56 Go to next message
Rondavouz
Messages: 5
Registered: July 2002
Junior Member
Hello , I´m having problems ordering a column.
I have two tables

table 1 | table 2
order_sequence #order_number | order_number heat_nr
1_________________10____________10______50
3_________________12____________12______52
3_________________11____________11______51
4_________________13____________13______53
________________________________________54
________________________________________55

is there any way to order tabel 2 (heat_nr)by using order_sequence in tabel 1?
I always come tp the point where I have to do a tabel1.order_number=tabel2.order_number in order not to get a hole bunch of rows

select heat_nr from table 2 where t1.order_number=t2.order_number <-- seems strange
order by order_sequnce;

This clearly leaves out the 54,55 value in table 2, but sorts the rest of the column correct. I would like to get the column order this way, but still show the elemnts that are not present in table 1,( values 54, 55 in this case)

To sum it up:
I want to see all heat_number, and the once with a order_sequnce number order by this, if no order_sequnce number still show me the heat_number.

I hope it makes some sence.
/Thx Rondavouz
Re: order problem [message #2662 is a reply to message #2654] Mon, 05 August 2002 08:25 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
To include all rows in t2 that do not have a corresponding row in t1, you need to outer join the tables:

select t2.heat_nr
  from table2 t2, table1 t1
 where t1.order_number (+) = t2.order_number
 order by t1.order_sequence;
Previous Topic: How to get X to Y rows without using "distinct" or "group by"
Next Topic: Index drops on table drops !!
Goto Forum:
  


Current Time: Tue Apr 23 17:04:06 CDT 2024