?
Solved

SQL: Reorder Output columns?

Posted on 2011-09-07
8
Medium Priority
?
387 Views
Last Modified: 2012-05-12
I am doing a cross join on 2 result sets that only have one row of information each (the first is returning a count and a sum, the second returns a count)

I would like to reorder the results set.

Currently the results are A, B, C

I would like it to be A, C, B

Is there a way to achieve what I would like?  A specific operator/command?
0
Comment
Question by:simplyfemales
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:Forefront_Data_Solutions
ID: 36499803
ORDER BY A, C, B
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 36499804

Just list the columns in the order you want

SELECT A, C, B
FROM TABA
CROSS JOIN TABB
0
 
LVL 8

Expert Comment

by:Forefront_Data_Solutions
ID: 36499808
As an example:

Select AB, CD, EF
From MyTable
Where AB='12'
Order by AB, EF, CD
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 8

Accepted Solution

by:
Forefront_Data_Solutions earned 2000 total points
ID: 36499814
ahh, I think I misunderstood the question.  Just select the fields in the order that you want:

Select A, C, B
From MyTable
0
 

Author Closing Comment

by:simplyfemales
ID: 36499842
Forefront.  I was trying to overthink this.  Simply by nesting the whole thing and then selecting in the order I want is the easiest solution.

Thanks for the smack upside the head.  DOH!
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 36499848
Exactly how is that answer different from #36499804
0
 

Author Comment

by:simplyfemales
ID: 36499912
Ewangoya, I was probably a little vague in my question, but the cross tabs inclusion in your answer made my mind go in a different direction.  The answer from forefront bounced my mind to the nesting thought and that's why I gave it the solution.

I know I ask stupidly simplistic questions and you have helped me previously and I appreciate it very much.
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 36499916

No problem
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question