select top 10 * from 表a order by id desc
[union] all
select top 10 * from 表a order by CategoryID desc
[union] all
select top 10 * from 表a order by DepartmentID将[union]的[]去掉

解决方案 »

  1.   

    --同意楼上的,不过。我的union 可以不加[]也能发出来~!:D
    select top 10 * from 表a order by id desc
    union all
    select top 10 * from 表a order by CategoryID desc
    union all
    select top 10 * from 表a order by DepartmentID
      

  2.   

    select * from
    (select top 10 * from 表a order by id desc) a
    [union] all
    select * from
    (select top 10 * from 表a order by CategoryID desc) b
    [union] all
    select * from
    (select top 10 * from 表a order by DepartmentID) c
      

  3.   

    sorry 楼上的老大,我的写法有问题!:(
      

  4.   

    select *
    from 表A
    where ID in
         (
            select top 10 id
            from 表A
            order by id desc
            union
            select top 10 id
            from 表A
            order by CategoryID desc
            union
            select top 10 id
            from 表A
            order by DepartmentID desc
         )
      

  5.   

    select top 10 * from 表a order by id desc
    union all
    select top 10 * from 表a order by CategoryID desc
    union all
    select top 10 * from 表a order by DepartmentID
      

  6.   

    select top 10 * from a order by id desc
    union all
    select top 10 * from a order by CategoryID desc
    union all
    select to 10 * from a order by DepartmentID
      

  7.   

    -------生成测试数据
    create table abc(id char(10),S01 int,S02 int,S03 int,S04 int,S05 int)
    insert into abc select '1','32','2','4','23','23'
    insert into abc select '2','58','6','4','23','23'
    insert into abc select '3','63','2','41','23','23'
    insert into abc select '4','31','2','9','23','84'
    insert into abc select '5','11','45','40','23','23'
    insert into abc select '6','39','22','14','80','23'
    insert into abc select '7','52','21','43','23','23'
    insert into abc select '40','31','12','89','23','84'
    insert into abc select '80','11','20','46','23','23'
    insert into abc select '696','39','29','45','80','23'
    insert into abc select '7415','52','2220','4','23','23'
    select * from abc
    -----查询数据,排序
    select top 10 s01 from abc order by s01
    select top 10 s02 from abc order by s02 
    select top 10 s03 from abc order by s03----删除测试表
    delete  abc
      

  8.   

    如果我的DepartmentID是不一定的呢?
    有没有办法查处来了?
    分不够可以在家
    急啊,兄弟们