Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
A simple order by question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
John Poulakos

New User


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

PostPosted: Tue Aug 28, 2012 7:29 pm    Post subject: A simple order by question
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10373
Location: italy

PostPosted: Tue Aug 28, 2012 7:35 pm    Post subject: Reply to: A simple order by question
Reply with quote

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

Senior Member


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

PostPosted: Tue Aug 28, 2012 7:56 pm    Post subject:
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

Active Member


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

PostPosted: Tue Aug 28, 2012 7:58 pm    Post subject:
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

Site Director


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

PostPosted: Tue Aug 28, 2012 8:02 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1826
Location: NY,USA

PostPosted: Wed Aug 29, 2012 3:05 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts question about dfsms management clas... Hervey Martinez IBM Tools 0 Tue Oct 10, 2017 6:19 pm
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am
No new posts Sorting on text - but in non-alphabet... Roy Ware SYNCSORT 5 Wed Aug 23, 2017 9:15 pm
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us