how to order rows in pl/sql?
i have a table of numbers, i want to order in ascending order if id of table is odd and descending if id is even
RainaAnja -3 Light Poster
Recommended Answers
Jump to PostFollowing 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
Jump to Post"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 …
All 5 Replies
Alberto Bucur 0 Junior Poster
urtrivedi 276 Nearly a Posting Virtuoso
jwenting 1,905 duckman Team Colleague
RainaAnja -3 Light Poster
Alberto Bucur 0 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.