Ciao,
queste sono due possibili soluzioni scritte per Sql Server
ma che suppogo si possono adattare anche ad altri db.
codice:
--crezione e popolamento tabella di prova
create table tord(ID int)
go
Insert into tord values(1)
Insert into tord values(2)
Insert into tord values(3)
Insert into tord values(4)
Insert into tord values(5)
go
-- soluzione 1
select 1 as ord1, id as ord2 , *
from tord where id<=2
Union all
select 2 as ord1, (-1*id ) as ord2 , *
from tord where id>2
Order by ord1, ord2
codice:
-- soluzione 2
Select q1.* from
(
select top 99.999999999 percent * from tord
where id<=2 order by id asc
) as q1
Union all
Select q2.* from
(
select top 99.999999999 percent * from tord
where id>2 order by id desc
) as q2