获取所有无效工作的公司

时间:2012-06-28 07:32:28

标签: sql-server

tbl_posting_job_info

tbl_posting_job_info

tbl_company_info

company_id     companyname
---------------------------
1              XYZ
4              PQR
8              LMN

现在我想了解一家公司的信息,该公司甚至没有一个“活跃”的工作。

2 个答案:

答案 0 :(得分:2)

select  *
from    tbl_company_info c
where   not exists
        (
        select  *
        from    tbl_posting_job_info j
        where   j.company_id = c.company_id
                and j.status = 'active'
        )

答案 1 :(得分:0)

select  *
from    tbl_company_info a
where   Isnull((
        select  count(*)
        from    tbl_posting_job_info b
        where   a.company_id = b.company_id
                and a.status = 'active'
        ),0) = 0