Solved

SQL: Reorder Output columns?

Posted on 2011-09-07
8
364 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:Forefront_Data_Solutions
Comment Utility
ORDER BY A, C, B
0
 
LVL 32

Expert Comment

by:ewangoya
Comment Utility

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
Comment Utility
As an example:

Select AB, CD, EF
From MyTable
Where AB='12'
Order by AB, EF, CD
0
 
LVL 8

Accepted Solution

by:
Forefront_Data_Solutions earned 500 total points
Comment Utility
ahh, I think I misunderstood the question.  Just select the fields in the order that you want:

Select A, C, B
From MyTable
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Closing Comment

by:simplyfemales
Comment Utility
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:ewangoya
Comment Utility
Exactly how is that answer different from #36499804
0
 

Author Comment

by:simplyfemales
Comment Utility
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:ewangoya
Comment Utility

No problem
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now