Solved

SQL: Reorder Output columns?

Posted on 2011-09-07
8
371 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 8

Accepted Solution

by:
Forefront_Data_Solutions earned 500 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Webservices in T-SQL 3 41
database level memory cache..? 8 37
Index and Stats Management-Specific tables 8 39
T-SQL: problem comparing datetime 4 48
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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