ORDER BY

多表查询造成重复字段进行排序造成错误,可以对数据进行封装,把字段唯一化,再进行排序

select * from (
select
t1.*, t2.REQ_CLASS_ID, t2.REQ_TYPE_NAME, t3.REQ_CLASS_NAME,
submitter.user_name as SUBMIT_USER_NAME,
cmo.user_name as CMO_NAME,
t4.user_name as MODIFY_USER_NAME,
dic_reqLevel.Dictionary_Name as REQ_LEVEL_NAME,
dic_reqStatus.Dictionary_Name as REQ_STATUS_NAME
from SRM.REQ_REQUIREMENTINFO t1
left join SRM.REQ_REQUIREMENTTYPE t2
on t1.REQ_TYPE_ID = t2.ID
left join SRM.REQ_REQUIREMENTCLASS t3
on t2.REQ_CLASS_ID = t3.ID
left join BSP.SYS_USERINFO submitter
on t1.user_id = submitter.id
left join BSP.SYS_USERINFO cmo
on t1.cmo = cmo.id
left join BSP.SYS_USERINFO t4
on t1.MODIFY_USER = t4.id
left join (select * from sys_dictionary dic where dic.dictionary_type_id = 6) dic_reqLevel
on t1.REQ_LEVEL = dic_reqLevel.Dictionary_Code
left join (select * from sys_dictionary dic where dic.dictionary_type_id = 5) dic_reqStatus
on t1.REQ_STATUS = dic_reqStatus.Dictionary_Code
<![CDATA[ where 1=1 ]]>
<if test="reqName != null and reqName != ''">
and REQ_NAME like concat(concat('%',#{reqName, jdbcType=VARCHAR}),'%')
</if>
<if test="reqLevel != null and reqLevel != ''">
and REQ_LEVEL like concat(concat('%',#{reqLevel, jdbcType=VARCHAR}),'%')
</if>
<if test="reqStatus != null and reqStatus != ''">
and REQ_STATUS like concat(concat('%',#{reqStatus, jdbcType=VARCHAR}),'%')
</if>
<if test="reqClassId != null and reqClassId != ''">
and REQ_CLASS_ID = #{reqClassId, jdbcType=DECIMAL}
</if>
<if test="reqTypeId != null and reqTypeId != ''">
and REQ_TYPE_ID = #{reqTypeId, jdbcType=DECIMAL}
</if>
<if test="userId != null and userId != ''">
and USER_ID = #{userId, jdbcType=DECIMAL}
</if>
<if test="cmo != null and cmo != ''">
and CMO = #{cmo, jdbcType=DECIMAL}
</if>
<if test="startTime != null and startTime != '' ">
and REQ_TIME >= to_date(#{startTime, jdbcType=VARCHAR},'yyyy-MM-dd / hh24:mi:ss')
</if>
<if test="endTime != null and endTime != '' ">
and REQ_TIME <![CDATA[<=]]> to_date(#{endTime, jdbcType=VARCHAR},'yyyy-MM-dd / hh24:mi:ss')
</if>
)
<if test="sortColumns != null and sortColumns !='' ">
ORDER BY ${sortColumns}
</if>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值