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 2005 Forums
 Transact-SQL (2005)
 Special sorting

Author  Topic 

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2007-08-09 : 05:06:03
Hi, I have this SP which simply returns all records, sorted by a name field, so it returns something like:

fred www.somewebsite.com
henry NULL
peter www.anotherwebsite.net
samuel NULL

What I would like to do, is to return the names with a website first, sorted by name, and then return the names without a website, sorted by name. So it should return this:

fred www.somewebsite.com
peter www.anotherwebites.com
henry NULL
samuel NULL


nr
SQLTeam MVY

12543 Posts

Posted - 2007-08-09 : 05:09:51
order by
case when name like '% www.%' then 1 else 2 end ,
name


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2007-08-09 : 05:17:37
Very nice...
Go to Top of Page
   

- Advertisement -