inblog logo
|
silver
    SQL문제풀기

    [SQL문제풀기] Number of violations

    silver's avatar
    silver
    Jan 05, 2026
    [SQL문제풀기] Number of violations
    Contents
    문제내가 작성한 정답

    문제

    StrataScratch - Number of violations
    StrataScratch
    StrataScratch - Number of violations
    https://platform.stratascratch.com/coding/9728-inspections-that-resulted-in-violations?code_type=7

    내가 작성한 정답

    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

    RSS·Powered by Inblog