Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 A Simple Sorting Question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-10 : 07:56:49
Jennifer writes "This is probably really easy but not sure how to handle. I'm running SQL server version 7.0 on a Windows 2000 machine I have a simple Select statement where I'm selecting Name,Link, and Category from the TrainingData table and joining TrainingCateoryRelate and TrainingCategory tables Where TCR.[Category ID] = 4 and TD.[InActive] = 0
ORDER BY TD.[Name].
A page of mine on the Intranet uses this select statement to give links to certain documents on a server.

Sample file names the select statement brings up are......
Advanced Inside Sales
Advanced Inside Sales Commitment Form
EDGE
EPEC Agreement Form
EPEC Experts
EPEC Manager Trainee Agreement
EPEC Train The Trainer
EPEC Training Policy

but I need to order the links so that EPEC Training Policy comes first then
EPEC Agreement Form
EPEC Manager Trainee Agreement
EPEC Experts and EPEC Train the Trainer.
Please Help!"

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-10 : 12:03:47
Not clear about ur requirement, but check the following:

Select * from
(Select .... from ur_tables .... join .... ) as Q1
Where FirstField like 'EPEC%'
Union
Select * from
(Select .... from ur_tables .... join .... ) as Q2
Where FirstField not like 'EPEC%'

Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-01-10 : 14:44:38

Select
column list...
from
Mytable
order by
case
when name like 'EPEC%'
then 0
else 1
end,
name


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -