日期:2014-05-17 浏览次数:20602 次
--> 测试数据:@T declare @表头 table([id] int,[cmaketime] int) insert @表头 select 1,6 union all select 1,7 union all select 1,8 union all select 2,12 union all select 2,13 union all select 2,14 union all select 3,25 union all select 3,26 union all select 3,28 --> 测试数据:@表体 declare @表体 table([id] int,[单价] int) insert @表体 select 1,3 union all select 2,5 union all select 3,6 select *,(select max([cmaketime]) from @表头 where id=t.id) as [cmaketime] from @表体 t /* id 单价 cmaketime ----------- ----------- ----------- 1 3 8 2 5 14 3 6 28 */