4
Contributors
5
Replies
21
Views
3 Years
Discussion Span
Last Post by albucurus
0

Hi,
You can do that with 2 selects:
For odd ids:
SELECT * FROM table WHERE MOD(ID,2) <> 0 ORDER BY column ASC
For even ids:
SELECT * FROM table WHERE MOD(ID,2) = 0 ORDER BY column DESC

0

Following query will show first even ids in desc and later it will show odd ids in asc

SELECT * FROM tablename  ORDER BY case when MOD(idcolumnname,2)=0 then -1 else 1 end * idcolumnname asc
0

"if id of table"? What "id of table"?
You make no sense.
The table has no id. If you select out of it and pass a record identifier you should only get 1 row so there's no need to sort anything.

Or are you maybe refering to an id of another table with which the one you intent to sort a selection from has a foreign key relationship?

0
i have table1
id col1 col2 col3 col4 col5
1   5    7   4     6    9
2   6    5   9     4    10
3   9    6   8     7    6
4   10   5   8     7    10

i want table to look like

id col1 col2 col3 col4 col5
1   4    5   6     7    9
2   10   9   6     5    4
3   6    6   7     8    9
4   10   10   8    7    5
if id is odd order by asc order 
if id is even order by desc order
0

Select each record, col1...col5 in a VARRAY(5) OF INTEGER, sort the VARRAY elements using buble-sort, depending on the id column from table.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.