IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

A simple order by question


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
John Poulakos

Active User


Joined: 13 Jun 2012
Posts: 178
Location: United States

PostPosted: Tue Aug 28, 2012 7:29 pm
Reply with quote

I'm just verifying this, does:

ORDER BY 1 DESC, 2

mean the first value is descending and the second is a ascending?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Aug 28, 2012 7:35 pm
Reply with quote

what does the manual say about it ???
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Aug 28, 2012 7:56 pm
Reply with quote

The ORDER BY clause allows you to sort the rows in your result set. Consider this
Code:
SELECT columns
FROM tables
WHERE predicates
ORDER BY column ASC/DESC

as I've stated earlier, the ORDER BY clause sorts the result set based on the columns specified. If the ASC or DESC value is omitted, it is sorted by ASC or ASC is default.

You can also sort by position in the SELECT List, as you did.

Keeping above in mind -- your assumption sounds correct, however, I've not verifed it (I leave RTFM for you, as Enrico suggests).
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Aug 28, 2012 7:58 pm
Reply with quote

Good question John - because this is so hard to test.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 28, 2012 8:02 pm
Reply with quote

Hello,

If you find something n the documentation that is not clear, post what you found and your doubt.

Someone here will be able to clarify.

There is a link to "IBM Manuals" at the top of the page.

Our intent is for the user to learn (both the info and where to find it) not for us to provide a manual reading service . . .
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Wed Aug 29, 2012 3:05 pm
Reply with quote

Hi All,

I just tried out this and I found it like as soon as it encounters either'ASC' or 'DESC' it does sorting and whatever you specified after ',' it will be in
ASC order.
So in your case order by 1 desc will be in place and '2' will be in asc order for every same value of 1.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Rotate partition-logical & physic... DB2 0
No new posts Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts Run a simple JOB as Started Task All Other Mainframe Topics 4
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
Search our Forums:

Back to Top