Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
TableAと呼ばれる次の単純なテーブルがあります
ID SomeVal 1 10 1 20 1 30 2 40 2 50 3 60
SomeVal が同じ ID 値の最小値である行のみを選択したいと考えています。したがって、私の結果は次のようになります。
1 10 2 40 3 60
SQL で Group By が必要だと思いますが、その方法がわかりません。ご協力いただきありがとうございます。
SELECT ID, MIN(SomeVal) FROM [TableName] GROUP BY ID
Group byは、グループ化されたすべての一意の値に対して集計関数(MIN)を実行し、結果を返します。
私はこれがあなたが必要とすることをするだろうと思います:
Select ID, Min(SomeVal) From MyTable Group By ID