SQL表中数据对应
Ta:
月份编码工瓷
12113900
22113780
Tb:
编码奖金
2113200
Tc(目的表):
月份编码工资奖金
121139000
22113780200
Ta.编码=Tb.编码
把Tb的奖金对应到Ta最大月份中去,请问SQL怎么写
[解决办法]
select a.*,奖金=case when 月份=(select max(月份) from ta where 编码=a.编码) then 奖金 else 0 end from ta a inner join tb b on a.编码=b.编码