Solved

Order by and have one value always on top

Posted on 2010-08-23
2
413 Views
Last Modified: 2012-05-10
NBW       13000
SHOPN     7888
PFF       90
Warr      20

I want to select and order it such a way that SHOPN is always on top. What I did was to add another column to this table and added ID and ordered it by

ID (added 1 for SHOPN, 2 for NBW, 3 for PFF, 4 for Warr)

That's an over kill. Is there any other way to always have SHOPN on top? I dont want to use the Sale column..that might change.
0
Comment
Question by:Camillia
2 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 33506705
Order by Case when col1 = 'SHOPN' then 1 else 2 end ASC, col1
0
 
LVL 3

Expert Comment

by:ehartfield2002
ID: 33506721
Are NBW, SHOPN, PFF, and Warr all field names?

If not, i.e., if they're really values, you could just go

select * from table where field = 'SHOPN' union

select * from table where field != 'SHOPN' order by field.

The phrasing of your question is a bit confusing.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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