Solved

Order by and have one value always on top

Posted on 2010-08-23
2
411 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
Comment Utility
Order by Case when col1 = 'SHOPN' then 1 else 2 end ASC, col1
0
 
LVL 3

Expert Comment

by:ehartfield2002
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

6 Experts available now in Live!

Get 1:1 Help Now