数据库
首页 > 数据库> > 数据库政策相关查询

数据库政策相关查询

作者:互联网

-- is_mixture为是否为混合出资1是0否
/*” 查询出申请惠企政策已通过,待评价,已评价状态的总金额 “*/
SELECT
    TRUNCATE (SUM(graded_money), 2)
FROM
    gj_policy_apply_management
WHERE
    apply_subject = 1
AND graded_money != 'NULL'
-- AND is_mixture = 1
AND state IN ('2', '3', '4')

/*” 查询出申请惠民政策已通过,待评价,已评价状态的总金额 “*/
SELECT
    TRUNCATE (SUM(graded_money), 2)
FROM
    gj_policy_apply_management
WHERE
    apply_subject = 2
AND graded_money != 'NULL'
-- AND is_mixture = 1
AND state IN ('2', '3', '4')

/*” 查询出申请党群工作部的惠企政策已通过,待评价,已评价状态的总金额 “*/
SELECT
    TRUNCATE (SUM(graded_money), 2)
FROM
    gj_policy_apply_management AS A,gj_policy_management AS B
WHERE
A.policy_id = B.id
AND B.apply_subject = 1
AND A.graded_money != 'NULL'
-- AND is_mixture = 1
AND A.state IN ('2', '3', '4')
AND B.competent_department  = 3

/*” 查询出申请中关村的惠民政策已通过,待评价,已评价状态的总金额 “*/
SELECT
    TRUNCATE (SUM(graded_money), 2)
FROM
    gj_policy_apply_management AS A,gj_policy_management AS B
WHERE
A.policy_id = B.id
AND B.apply_subject = 2
AND A.graded_money != 'NULL'
-- AND A.is_mixture = 2
AND A.state IN ('2', '3', '4')
AND B.competent_department  = 1

/*” 查询出申请惠企政策已通过,待评价,已评价状态的所有政策id且去重 “*/
SELECT DISTINCT
    policy_id
FROM
    gj_policy_apply_management
WHERE
    apply_subject = 1
AND graded_money != 'NULL'
-- AND is_mixture = 1
AND state IN ('2', '3', '4')

/*” 查询出申请惠民政策已通过,待评价,已评价状态的所有政策id且去重 “*/
SELECT DISTINCT
    policy_id
FROM
    gj_policy_apply_management
WHERE
    apply_subject = 2
AND graded_money != 'NULL'
-- AND is_mixture = 1
AND state IN ('2', '3', '4')

/*” 查询出申请惠企政策已通过,待评价,已评价状态的所有政策id且去重,并通过政策id查出政策名称、政策内容、备注 “*/
SELECT DISTINCT
    B.policy_name,B.policy_content,B.remark
FROM
    gj_policy_apply_management AS A,gj_policy_management AS B
WHERE
A.policy_id = B.id
AND B.apply_subject = 1
AND A.graded_money != 'NULL'
-- AND A.is_mixture = 1
AND A.state IN ('2', '3', '4')

/*” 查询出申请惠民政策已通过,待评价,已评价状态的所有政策id且去重,并通过政策id查出政策名称、政策内容、备注 “*/
SELECT DISTINCT
    policy_name,policy_content,remark
FROM
    gj_policy_management
WHERE
    gj_policy_management.id = ANY (
        SELECT DISTINCT
            policy_id
        FROM
            gj_policy_apply_management
        WHERE
            apply_subject = 2
        AND graded_money != 'NULL'
--  AND is_mixture = 1
        AND state IN ('2', '3', '4')
    )

标签:management,graded,数据库,gj,查询,apply,policy,相关,id
来源: https://blog.csdn.net/yzTestGroup/article/details/121327726