Solved

Order by and have one value always on top

Posted on 2010-08-23
2
412 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

19 Experts available now in Live!

Get 1:1 Help Now