среда, 10 сентября 2008 г.

Первая запись с ORDER BY

При использовании выражения ORDER BY бывает необходимо поставить какую-то конкретную запись, первой в результирущем наборе данных.



create table #www(id int)
insert into #www (id) values (1)
insert into #www (id) values (2)
insert into #www (id) values (4)
insert into #www (id) values (5)
insert into #www (id) values (5)
insert into #www (id) values (4)
insert into #www (id) values (7)
insert into #www (id) values (8)
insert into #www (id) values (44)
insert into #www (id) values (4)
select id from #www ORDER BY NULLIF(ID,4)
drop table #www

Комментариев нет:

Locations of visitors to this page