[SQL문제풀기] Number of violations

silver's avatar
Jan 05, 2026
[SQL문제풀기] Number of violations

문제

내가 작성한 정답

MySQL

select year(inspection_date) year, count(distinct violation_id) from sf_restaurant_health_violations where business_name = 'Roxanne Cafe' group by year(inspection_date);

PostgreSQL

select extract(year from inspection_date) as year, count(distinct violation_id) from sf_restaurant_health_violations where business_name = 'Roxanne Cafe' group by extract(year from inspection_date);

Oracle

select to_number(to_char(inspection_date,'yyyy'),9999) year, count(distinct violation_id) from sf_restaurant_health_violations where business_name = 'Roxanne Cafe' group by to_number(to_char(inspection_date,'yyyy'),9999);
Share article

silver