Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
546 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Tricks to change column order in SQL and in Power BI |
---|
Two little tricks to change the order of columns in SQL Server Management Studio and Power BI Query Editor, which (to our shame?) we've only just discovered. |
In this blog
Do you know either of these tricks?
So you've written or run a query to list out some films, but want to show the film title first:
A query listing some films.
Obviously one way to do this is to change your SQL:
SELECT
f.Title
, f.OscarWins
, f.RunTimeMinutes
FROM
Film as f
However, you can also click and drag columns in the Results window:
Click and drag the Title column and release your mouse button exactly as shown above.
Despite the underwhelming mouse pointer support, this does actually work!
This obviously won't affect the underlying SQL, but can be useful when you're looking at (or copying) the output from a query.
I think this trick is even more unexpected. Suppose you want to reverse the order of these first 3 columns in Power BI's Query Editor:
The title should go first, followed by the Oscar nominations, followed by the Oscar wins.
To do this, select the Title column first:
Start with this column selected.
Now hold the Shift key down and click on the first column:
Click on the OscarWins column with the Shift key held down.
Now drag the last column you selected over the first:
Click on the OscarWins column and drag it to the position shown (the column title bar is showing you the new order that you'll get), then release the mouse button.
Eureka!
It worked!
Here's hoping that someone, somewhere, will read these tips and it will change their life for the better in a small way.
Some other pages relevant to the above blog include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.