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)
 SQL statement to return query

Author  Topic 

froggy
Starting Member

14 Posts

Posted - 2006-10-25 : 02:24:47
Hi, in my database, there are multiple IDs. for each id in the role column, they will either be Immediate, Extended or Stand-down. In my query, they will group all IDs with the same role together and return them in an ASC order which is Extended, Immediate then Stand-Down. However, i would need the order to be Immediate, Extended then Stand-down. How is my SQL statement suppose to be?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-25 : 02:40:55
Homework?

select * from mytable
order by case when id = 'immediate' then 1 when id = 'extended' then 0 when id = 'stand-down' then 2 else 32767 end


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

froggy
Starting Member

14 Posts

Posted - 2006-10-25 : 03:00:26
Hihi, yupyup, this is a homework assignment which i got to do.
I have to create a website which return in the order Immediate, Extended, Stand-down. Do i simply insert the statement into my webpage, don't think it works. is there anything which i had missed?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-25 : 03:12:14
My suggested query will work for you. But I think you have to change some names to fit your platform.
Read the query and try to understand the logic behind the text.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -