2017-01-15 12 views
0

を満たしていない場合、私は「私が演じているプレーヤーを持っていないチーム名を選択したい 選択値別の列は、特定の条件

player:string | team:string | position:string 

jim | packers | qb 

jack | patriots | rb 

mark | texans | te 

tim | packers | wr 

のように見えるテーブルを持っていますqb "の位置にある。この場合、結果はチーム名の愛国者とテキサスを出すでしょう。以下は現在私が持っているものです。

select distinct team 
from Players 
where position <> 'qb' 
group by team 

答えて

1

あなたが形成グループごとに<> 'qb'を確認する必要があるので、これは、テーブル全体に適用されるとして、それは、通常のwhere句にすることはできません。私はこれをサブクエリで書く:

select distinct team 
from Players 
where team not in (
    select team 
    from Players 
    where position = 'qb' 
); 
関連する問題