sql语句

select 
d.sur_id,
a.user_id,
a.pf_id,
a.team_id as teamid,
b.user_name as tdfzr,
sum(c.post_num) as tdrs,
d.expedition_companyName as dcmb,
a.enter_time as qdsj
from law_team_setting as a 
LEFT JOIN law_staff as b ON a.user_id = b.user_acc
LEFT JOIN law_post_info as c ON a.team_id = c.team_id 
LEFT JOIN law_survey as d ON a.team_sur_id = d.sur_id
group by a.team_id
HAVING 1 = 1
<if test="user != null and user != '' ">
AND a.user_id  = concat(#{user, jdbcType=VARCHAR})
</if>
<if test="target != null and target != '' ">
AND d.sur_id  = concat(#{target, jdbcType=VARCHAR})
</if>
<if test="timeOne != null and timeOne != '' ">
<![CDATA[ AND qdsj >= #{timeOne} ]]>
</if>
<if test="timeTwo != null and timeTwo != '' ">
<![CDATA[ AND qdsj <= #{timeTwo} ]]>
</if>
and a.pf_id = #{pfId,jdbcType=VARCHAR}
LIMIT #{startRow},10




select count(*) TotalNum  from (
select 
d.sur_id,
a.user_id,
a.pf_id,
a.team_id,
b.user_name as tdfzr,
sum(c.post_num) as tdrs,
d.expedition_companyName as dcmb,
a.enter_time as qdsj
from law_team_setting as a 
LEFT JOIN law_staff as b ON a.user_id = b.user_acc
LEFT JOIN law_post_info as c ON a.team_id = c.team_id 
LEFT JOIN law_survey as d ON a.team_sur_id = d.sur_id
group by a.team_id
HAVING 1 = 1
<if test="user != null and user != '' ">
AND a.user_id  = concat(#{user, jdbcType=VARCHAR})
</if>
<if test="target != null and target != '' ">
AND d.sur_id  = concat(#{target, jdbcType=VARCHAR})
</if>
<if test="timeOne != null and timeOne != '' ">
<![CDATA[ AND qdsj >= #{timeOne} ]]>
</if>
<if test="timeTwo != null and timeTwo != '' ">
<![CDATA[ AND qdsj <= #{timeTwo} ]]>
</if>
and a.pf_id = #{pfId,jdbcType=VARCHAR}
) as info
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值