如何列出人事经理?

时间:2013-10-10 20:46:59

标签: sql

如何只查询人事经理列表?我尝试使用Distinct无济于事。这是我的数据的快照: 我有人GNumber(像一个ID)和人的经理GNumber应该使这个可行。谢谢。

First    Last        Gnumber     Department            ManagerGNumber   Title
Alex     Anderson    G000001     Corp                                   CEO
Brooke   Brown       G000002     Accounting            G000001          VP
Carol    Clark       G000003     Marketing             G000001          VP
David    Drew        G000004     Human Resources       G000001          VP
Walter   Watson      G000005     Finance               G000001          VP
Erin     Eisley      G000006     Tables                G000002          Director
Felicia  Ford        G000007     Accounting            G000002          Director
Grace    Griffin     G000008     IT                    G000003          Director
Henry    Howard      G000009     Sales                 G000003          Director
Ian      Iverson     G000010     Product Development   G000004          Director
Janice   Jones       G000011     Operations            G000004          Sr. Architect
Xenon    Xandruski   G000012     Sales                 G000005          Director
Karl     King        G000013     Human Resources       G000006          Sales Rep
Mike     Miller      G000014     Sales                 G000007          Sales Rep
Linda    Lewis       G000015     Accounting            G000006          Sales Rep
Nancy    Nash        G000016     Sales                 G000007          Sales Rep

1 个答案:

答案 0 :(得分:0)

如果您的基础数据库是基于SQL的,如果您能以某种方式实现此目标,那么它只会产生未在ManagerGnumber列中表示的人员:

select * 
from yourTable 
where Gnumber in (
    select distinct(ManagerGnumber) 
    from yourTable
);