• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

SQL: Reorder Output columns?

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
simplyfemales
Asked:
simplyfemales
  • 3
  • 3
  • 2
1 Solution
 
Forefront_Data_SolutionsCommented:
ORDER BY A, C, B
0
 
Ephraim WangoyaCommented:

Just list the columns in the order you want

SELECT A, C, B
FROM TABA
CROSS JOIN TABB
0
 
Forefront_Data_SolutionsCommented:
As an example:

Select AB, CD, EF
From MyTable
Where AB='12'
Order by AB, EF, CD
0
Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

 
Forefront_Data_SolutionsCommented:
ahh, I think I misunderstood the question.  Just select the fields in the order that you want:

Select A, C, B
From MyTable
0
 
simplyfemalesAuthor Commented:
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
 
Ephraim WangoyaCommented:
Exactly how is that answer different from #36499804
0
 
simplyfemalesAuthor Commented:
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
 
Ephraim WangoyaCommented:

No problem
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now