【发布时间】:2017-01-15 15:19:49
【问题描述】:
需要你的专家
当插入这样的查询时:
use tabelmantap
delete from T_CekUser
insert into T_CekUser(T_21SI)
select tbla.MASA
from
(
select * from T_21SI
union
select * from T_21SI
) as tbla
where tbla.THN_DATA = '2014' and tbla.KEY_NPWP = '01.576.555.5-123.000'
insert into T_CekUser(T_23SI)
select tblb.MASA from
(
select * from T_23SI
union
select * from T_23SI
) as tblb
where tblb.THN_DATA = '2014' and tblb.KEY_NPWP = '01.576.555.5-123.000'
所有查询都在 sql server 中的一行/一页查询中
我得到这样的结果:
T_21SI | T_23SI
1 null
2 null
3 null
4 null
null 2
null 3
累了,四处寻找答案或解决方案,因为我想成为这样:
T_21SI | T_23SI
1 2
2 3
3 null
4 null
null null
null null
所有文件类型都是 int
我已经从两个表中使用 select 进行插入(使用内部联接),但结果不是预期的
任何帮助将不胜感激..谢谢
【问题讨论】:
-
实际上,您似乎正在尝试执行 PIVOT 我假设每一行都有特定的含义?
-
好吧..数据是月份数..是的,它的支点..知道如何不使用联合来支点该数据
标签: sql-server