-- SQL实现
select 10.00 as amount,'X031' as store_code
union
select 20.00 as amount,'D033' as store_code
-- MyBatis实现
select
sd.daily_init_target_money / tmp.reality_money as targetImplRate,
tmp.reality_money as salesAmount,
sd.store_code
from store_daily_sales_analyze sd
join (
<foreach collection="storeTargetDtoListList" item="storeTargetDtoListItem" index="index" separator="union">
select
#{storeTargetDtoListItem.storeCode} as store_code,
#{storeTargetDtoListItem.salesAmount} as reality_money
</foreach>
)tmp on tmp.store_code = sd.store_code
<where>
<include refid="query_whereConditions"/>
</where>
来源:CSDN
作者:国强_dev
链接:https://blog.csdn.net/t1g2q3/article/details/103928311