Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Order by and have one value always on top

Posted on 2010-08-23
2
Medium Priority
?
436 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
[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
2 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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