Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Order By query?

Status
Not open for further replies.

redgenie

Programmer
Aug 10, 2000
36
GB
I'm trying to perform a select that orders the results alphabetically yet always puts a specific one last.

Ie.

Fred, Jane, Sharon, Tracy, Bill

I always want Bill to be last even though the rest are in alphabetical order.

Any help would be greatly appreciated.

Something along the lines of:

Code:
select Name from People order by Name, 'Bill';
 
Hi

How about something like

SELECT * FROM MyTable ORDER BY IIF([FirstName]='Bill',"ZZZZZZZZ",[FirstName])

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I use something like :-

Code:
SELECT Name, 1 As SO FROM People WHERE Name <> 'Bill' 
UNION
SELECT Name, 2 As SO FROM People WHERE Name = 'Bill' 
ORDER BY SO, Name;

( SO stands for SortOrder - You can use any name you like )




'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top