Home » SQL & PL/SQL » SQL & PL/SQL » Re: SQL query problem
Re: SQL query problem [message #2931] Thu, 22 August 2002 09:37 Go to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You didn't describe your requirements, so I will guess that you want Test6 and Test7 to appear at the end of the result (even though Test7 is not identified correctly in your sample result set). I would just add an artificial amount to those aend values to force them to the end:

sql>select *
  2    from end_details
  3   order by decode(descr, 'Test6', aend + 1000, 'Test7', aend + 1000, aend);
 
     AEND      BEND DESCR
--------- --------- -----
       11        22 Test1
       22        11 Test4
       33        44 Test2
       55        66 Test3
       65        45 Test5
       45        65 Test7
       88        99 Test6
 
7 rows selected.
Re: SQL query problem [message #2936 is a reply to message #2931] Fri, 23 August 2002 00:28 Go to previous messageGo to next message
Prasad Joshi
Messages: 3
Registered: August 2002
Junior Member
Hello Todd Barry

Thanks a lot for such prompt response.

My basic intention is to arrange the output based on the aend and bend values.

I mean 'descr' is not important in the output.
Impotant is say aend = 11 and bend = 22 (Say first occurence ) then in the output immediate row should be aend = 22 and bend = 11 (of course if occuring in the subsequent rows).And same applicable for all possible occurences.Say aend=33 and bend=44 then next row of it should be aend=44 and bend=33 if occuring in subsequent result set.And such result set for entire table rows.

Are u getting my point ?.

Prasad
Re: SQL query problem [message #2946 is a reply to message #2936] Fri, 23 August 2002 18:26 Go to previous message
Eric Myers
Messages: 13
Registered: August 2002
Junior Member
Prasad,

If I understand correctly, for each row in the table you want the query to return aend, bend on a row then on new row return bend, aend. Then get next row from the table and so on.

Try this (I'm at home & can't build a table to try but should work). Please e-mail me and let me know if it works.

select aend, bend ||
chr(10)||
bend, aend
from end_details;

BTW, CHR(10) is a carriage return. You have to concatenate it with the other fields as above. If you
just separate it with a comma as with a regular column then it won't force a carriage return.

Give it a try.

Eric
Previous Topic: Execute statements after every 'Enter'
Next Topic: I thought this was simple, but...
Goto Forum:
  


Current Time: Thu Apr 25 11:39:56 CDT 2024