我需要在where条件中获取子查询列名称

时间:2017-05-12 14:23:01

标签: mysql

这是我的查询,我需要在没有NULL的条件下检查子查询列previousenddate。

SELECT pa.policy_id,
    pa.person_id,
    (
        SELECT COUNT(pas.person_id)
        FROM `package_assignments` pas
        WHERE pas.person_id = pa.person_id
        GROUP BY pas.person_id
        ) AS Member_Count,
    pe.full_name,
    pa.start_date,
    pa.end_date,
    (
        SELECT p.end_date
        FROM `package_assignments` p
        WHERE p.person_id = pa.person_id
        ORDER BY p.end_date DESC LIMIT 1,
            1
        ) previousenddate
FROM `package_assignments` pa,
    persons pe
WHERE end_date BETWEEN "2017-04-01"
        AND "2017-04-30"
    AND pa.person_id = pe.id
    AND pa.rmhc_location = 5006
    AND previousenddate > 1

我需要检查previousenddate列而不使用Null For Eg:其中previousenddate<> ' NULL'

0 个答案:

没有答案