SQL DISTINCTとCOUNTを組み合わせてデータ種類をカウントする

参考: https://style.potepan.com/articles/22701.html

sample_type_idの種類と、それぞれのsample_type_id毎のis_newフラグの種類数を洗い出せる。

SELECT sample_type_id, count(DISTINCT is_new) as is_new_count
FROM samples
GROUP BY sample_type_id