<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>