Home » RDBMS Server » Server Administration » Query retrieving
Query retrieving [message #372515] Sat, 17 February 2001 07:22 Go to next message
Arjun Vakharia
Messages: 5
Registered: February 2001
Junior Member
How do I retrieve a same column in a table in ascending and descending values at a time?

eg. rollno rollno
1 3
2 2
3 1
Re: Query retrieving [message #372527 is a reply to message #372515] Tue, 20 February 2001 06:11 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
Setup:

Table TEMP:

Name Null? Type
--------- -------- ----
COL_1 NUMBER(5)

Data:
COL_1
---------
1
2
4
8
16
32
64

Query:

SELECT t1.col_1
,t2.col_1
FROM (select col_1,rownum r from temp) t1
,(select col_1,rownum r from temp) t2
WHERE t1.r+t2.r = (SELECT 1+count(*) FROM temp)

Hope this helps
Re: Query retrieving [message #372528 is a reply to message #372515] Tue, 20 February 2001 06:12 Go to previous messageGo to next message
John R
Messages: 156
Registered: March 2000
Senior Member
Setup:

Table TEMP:

Name Null? Type
--------- -------- ----
COL_1 NUMBER(5)

Data:
COL_1
---------
1
2
4
8
16
32
64

Query:

SELECT t1.col_1
,t2.col_1
FROM (select col_1,rownum r from temp) t1
,(select col_1,rownum r from temp) t2
WHERE t1.r+t2.r = (SELECT 1+count(*) FROM temp)

Hope this helps
Re: Query retrieving [message #372543 is a reply to message #372527] Wed, 21 February 2001 07:00 Go to previous messageGo to next message
Arjun Vakharia
Messages: 5
Registered: February 2001
Junior Member
I'll try it out.

John, Thanks a lot.
Re: John [message #372555 is a reply to message #372543] Thu, 22 February 2001 03:22 Go to previous message
Arjun Vakharia
Messages: 5
Registered: February 2001
Junior Member
yr query is perfectly engineered... but,
it is not in ascending or descending order..
Thanks for yr reply
Previous Topic: Re: Passthrough query
Next Topic: Q: SELECT with LEVEL
Goto Forum:
  


Current Time: Sat May 18 07:38:42 CDT 2024