<select id="statisticalHallProfit" parameterType="UsGameRecordDetailQuery" resultType="java.util.HashMap">
select a.game_type,(SELECT SUM(amount) from us_game_record_detail
where win_loss="0"
<if test="openCardTime != null">
and open_card_time >= #{openCardTime,jdbcType=TIMESTAMP}
</if>
<if test="openCardTime1 != null">
and open_card_time <= #{openCardTime1,jdbcType=TIMESTAMP}
</if>) c,
(SELECT SUM(amount) from us_game_record_detail
where win_loss="1"
<if test="openCardTime != null">
and open_card_time >= #{openCardTime,jdbcType=TIMESTAMP}
</if>
<if test="openCardTime1 != null">
and open_card_time <= #{openCardTime1,jdbcType=TIMESTAMP}
</if>) d,
(SELECT SUM(amount) from us_game_record_detail
where win_loss="0"
<if test="openCardTime != null">
and open_card_time >= #{openCardTime,jdbcType=TIMESTAMP}
</if>
<if test="openCardTime1 != null">
and open_card_time <= #{openCardTime1,jdbcType=TIMESTAMP}
</if>)-(SELECT SUM(amount) from us_game_record_detail
where win_loss="1"
<if test="openCardTime != null">
and open_card_time >= #{openCardTime,jdbcType=TIMESTAMP}
</if>
<if test="openCardTime1 != null">
and open_card_time <= #{openCardTime1,jdbcType=TIMESTAMP}
</if>) e
from us_game_record_detail b
LEFT JOIN us_game_record a on a.game_record_id=b.game_record_id
where a.site_type="2"
group by a.game_type
</select>
分享一个子查询的mybatis动态sql
原创
©著作权归作者所有:来自51CTO博客作者码海兴辰的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:Java代码实现行转列
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
hive中定义一个子查询函数 hive case when 子查询
1.select语句1.1 指定列 1.select * from dealer_leads;2.select leads_id,dealer_id,create_time from dealer_leads;3.select e.leads_id,e.dealer_id,e.create_time from dealer_leads e;--2和3是等价的 当选择的列是数据集合类型时,
hive中定义一个子查询函数 case when 子查询 case when嵌套子查询 hive case when 满足多条件 hive round函数不起作用 -
mysql blod怎么显示
Mysql分布式系统: CAP标准:分布式系统最多可以实现其中的两点,常用的有AP和AC; C:一致性 &
mysql blod怎么显示 Linux Mysql-MHA mysql 服务器