select a=(select top 1 aa from [table] order by aa),b=(select aa from [table] where aa !=(select top 1 aa from [table] order by aa) and aa !=(select top 1 aa from [table] order by aa desc))
,c=(select top 1 aa from [table] order by aa desc)
from [table]

解决方案 »

  1.   

    改:
    select a=(select top 1 aa from [table] order by aa),b=(select aa from [table] where aa !=(select top 1 aa from [table] order by aa) and aa !=(select top 1 aa from [table] order by aa desc))
    ,c=(select top 1 aa from [table] order by aa desc)
      

  2.   

    declare @s varchar(1000)
    select @s=''
    select @s=@s+','+ ''''+aaa+'''' from tb3
    select @s=stuff(@s,1,1,'')
    select @s
    exec('select' +@s)
      

  3.   

    AAAA
    BBBB
    CCCC
    为同一行数据;为显示结果