sql条件选择查询

SELECT CUST_ID
        FROM IMP_CM_GROUP_CUST_REL
        where GROUP_ID =#{custGroupId} and
        cust_id in (
        <choose>
            <when test="type == '01'.toString()"> -- 机构
                SELECT DISTINCT CUST_NUM FROM F_E_IMP_CUST_BELONG_ORG
                WHERE BELONG_ORG_ID IN (
                SELECT ORG_ID FROM SYS_ORG_VIEW o
                WHERE o.ORG_SEQ LIKE '%,' || #{orgId} || ',%'
                )
            </when>
            <when test="type == '02'.toString()"> -- 条线
                SELECT distict CUST_NUM FROM F_E_IMP_CUST_BELONG_MGR
                WHERE BELONG_TEAM_ID = (
                select team_id from admin_sm_team_info where team_type = #{teamType}
                )
            </when>
        </choose>
        )

  

posted @ 2023-02-15 09:43  红尘沙漏  阅读(45)  评论(0编辑  收藏  举报