Solved

Order by and have one value always on top

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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