Home » Developer & Programmer » Forms » SELECT FROM MIDDLE OF A TABLE
SELECT FROM MIDDLE OF A TABLE [message #131575] Mon, 08 August 2005 06:21 Go to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

hii
i have that table "name"
i select from it "code" so that the o/p is like that
SELECT CODE FROM name;

CODE
---------
hr
hsoft
hrub
hrecy
hdus
hf
hw
FS
FT
SF
dm

i want the o/p is to be previewed from the reocrd "hw" for example and continue displaying in a circuler way so that the o/p is like that

CODE
-------
hw
FS
FT
SF
dm
hr
hsoft
hrub
hrecy
hdus
hf
Re: SELECT FROM MIDDLE OF A TABLE [message #131580 is a reply to message #131575] Mon, 08 August 2005 06:57 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
At first glance:
Given a table like this:
SQL> select * from mhe_foo
  2    order by thevalue ASC
  3  /

THEVALUE
----------
FS
FT
SF
dm
hdus
hf
hr
hrecy
hrub
hsoft
hw
You can do this
SQL> SELECT   thevalue
  2      FROM (SELECT thevalue
  3                 , RANK () OVER (ORDER BY thevalue ASC) rn
  4              FROM mhe_foo)
  5  ORDER BY DECODE (GREATEST (thevalue, 'dm'), thevalue, rn, 'dm', rn * 100)
  6  /

THEVALUE
----------
dm
hdus
hf
hr
hrecy
hrub
hsoft
hw
FS
FT
SF

11 rows selected.
The above example started off with 'dm' and worked around from there.


MHE
Re: SELECT FROM MIDDLE OF A TABLE [message #131659 is a reply to message #131575] Mon, 08 August 2005 19:28 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I can't 'see' your sort order. What is your desired sort order?

David
Previous Topic: Q about related record group?pls quickly .........
Next Topic: pls urgent cursor trnsfters from one item to another item
Goto Forum:
  


Current Time: Thu Sep 19 23:38:45 CDT 2024