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
 Transact-SQL (2000)
 Two sort order

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-03-03 : 07:29:29
WaaX writes "Let say this table:

CREATE TABLE dbo.Tasks
(
taskId int NOT NULL,
task char(10) NULL,
priority int NULL,
date_added datetime NULL
) ON [PRIMARY]


taskId is the ID, primary
task is the todo: eat, sleep, work..
priority is 1 to 5
date_added is when this task was added.


I want to sort it by priority, highest first and by date_added oldest first.

so if two task with the same priority, the oldest one will come first.

Is this possible?"

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-03-03 : 07:38:30
select * from tasks
order by priority DESC, date_added ASC

- Jeff
Go to Top of Page
   

- Advertisement -