8,497
社区成员
发帖
与我相关
我的任务
分享
select
a.code,
b.name,
(select top 1 isnull(desc,'') from tb_c where code = a.code and YEAR(keepdate) =YEAR(@date) and MONTH(keepdate) = '1' )
as N'1月描述'
from tb_a a
left join tb_b b on a.id = b.id
select
a.code,
b.name,
(select top 1 isnull(desc,'') from tb_c where code = a.code and YEAR(keepdate) =YEAR(@date) and MONTH(keepdate) = '1' )
as N'1月描述',
(select top 1 isnull(desc,'') from tb_c where code = a.code and YEAR(keepdate) =YEAR(@date) and MONTH(keepdate) = '2' )
as N'2月描述',
(select top 1 isnull(desc,'') from tb_c where code = a.code and YEAR(keepdate) =YEAR(@date) and MONTH(keepdate) = '3' )
as N'3月描述'
from tb_a a
left join tb_b b on a.id = b.id
这样能拼出来么