表格ChannelReward和表格RewardSuppleSettle中都有一下几个字段JSMonth, ChannelNo, RewardSum, RewardItem。要将两个表中RewardSum>0的记录都显示在一个表中,可以使用联合查询
select * from(
SELECT JSMonth, ChannelNo, RewardSum, RewardItem, '1' AS ObjectType
FROM dbo.ChannelReward
WHERE (RewardSum > 0)
UNION ALL
SELECT JSMonth, ChannelNo, Reward AS RewardSum, ItemName AS RewardItem, '1' AS ObjectType
FROM RewardSuppleSettle
WHERE (Reward > 0))t where t.ChannelNo='1003'