私のデータベース テーブルには、0 または 1 を保持する 2 つの列があります。
ここで、タイプは and を意味type
し、性別はandです。Gender
0 => teacher
1 => student
0 => male
1 => female
教師、生徒、男性、女性の数を取得する単一の SQL クエリを作成するにはどうすればよいですか?
今私は持っています:
select COUNT(type) as teachers from my_table where type = 0; // Teachers
select COUNT(type) as students from my_table where type = 1; // Students
select COUNT(gender) as males from my_table where type = 0; // Males
select COUNT(gender) as females from my_table where type = 1; // Females
1回のクエリで実行できますか? もしそうなら、どのように?