次のデータを含むSybaseテーブルがあります(例)。
Users:
ID Type PlayerID
-------- ----------- -------------------
65823 1 (null)
65823 2 187
91817 1 (null)
37950 1 773
37950 1 (null)
37968 1 (null)
37968 1 773
72576 1 (null)
72576 1 (null)
ユーザーとタイプのすべての組み合わせを返したいのですが、特定のユーザーとタイプの組み合わせの例が複数ある場合は、 nullではないレコードのみを表示します。
たとえば、上記の表は次を返す必要があります
ID Type PlayerID
-------- ----------- -------------------
65823 1 (null) - although this is null the type/id is unique
65823 2 187
91817 1 (null) - this is null but is a unique type/id
37950 1 773
37968 1 773 - this is included and the id/type that has a null player id isn't
72576 1 (null) - this is a unique type/id
これまで、group by、haing、inner joinsを使用してクエリを調べてきましたが、探している結果に一致する方法を見つけることができませんでした。
group by、PlayerIDでmaxを使用するなども検討しましたが、集計関数はnull値を無視します。
一意のID/タイプのペアとそのプレーヤーIDを返すにはどうすればよいですか?
-
ポールからの質問:
ID Type PlayerID
-------- ----------- -------------------
65823 2 187
37950 1 773
37968 1 773