日期:2014-05-17  浏览次数:20340 次

排列
将数列1.2.3.4.5.6.7.8.9.10重新排列后输出为5.4.3.2.1.10.9.8.7.6.

------解决方案--------------------




create table [a]([ID] int)
insert a
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 union all
select 8 union all
select 9 union all
select 10


select id,case when id<=5 then 0 else 1 end as num  from a order by num ,id desc




------解决方案--------------------
Order by (num-1)/5 ,num DESC 
------解决方案--------------------
2L的C#实现
List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var query = from i in list
                        orderby (i-1) / 5, i descending
                        select i;
            foreach (var i in query)
            {
                Console.WriteLine(i);
            }
            Console.ReadLine();

------解决方案--------------------
引用:




create table [a]([ID] int)
insert a
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7 union all
select 8 union all
select 9 union all
select 10


select id,case when id<=5 then 0 else 1 end as num  from a order by num ,id desc



不知道这位兄弟有没有看楼主说