日期:2014-05-17 浏览次数:20561 次
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (id nvarchar(2),T1 int,T2 int,T3 int,T4 int,T5 int,T6 int,T7 int)
insert into [TB]
select 'A',78,72,60,89,57,93,72 union all
select 'B',81,71,78,72,90,77,73
select * from [TB]
SELECT DISTINCT N.num
FROM    ( SELECT  *
            FROM    ( SELECT    id ,
                                'T1' AS col ,
                                T1 AS num
                      FROM      TB
                      WHERE     id = 'A'
                      UNION ALL
                      SELECT    id ,
                                'T2' AS col ,
                             &nb