-------------------------------------------------------- -- users テーブルについて、部署・役職・作成日ごとに件数を集計する -- (MySQL用) -------------------------------------------------------- SELECT u.department_code `部署コード`, u.role_code `役職コード`, DATE_FORMAT(u.created_at, '%Y-%m-%d') `作成日`, COUNT(*) `人数` FROM users u GROUP BY u.department_code, u.role_code, DATE_FORMAT(u.created_at, '%Y-%m-%d') ORDER BY u.department_code ASC