-- Database schema
| businesses : business_id [ INTEGER ] primary_key , name [ TEXT ] , address [ TEXT ] , city [ TEXT ] , postal_code [ TEXT ] , latitude [ REAL ] , longitude [ REAL ] , phone_number [ INTEGER ] , tax_code [ TEXT ] , business_certificate [ INTEGER ] , application_date [ DATE ] , owner_name [ TEXT ] , owner_address [ TEXT ] , owner_city [ TEXT ] , owner_state [ TEXT ] , owner_zip [ TEXT ] | inspections : business_id [ INTEGER ] inspections.business_id = businesses.business_id , score [ INTEGER ] , date [ DATE ] , type [ TEXT ] | violations : business_id [ INTEGER ] violations.business_id = businesses.business_id , date [ DATE ] , violation_type_id [ TEXT ] , risk_category [ TEXT ] , description [ TEXT ] |
-- -- What are the names of the establishments that met all the required standards for 4 consecutive years?

SELECT DISTINCT T4.name FROM ( SELECT T3.name, T3.years, row_number() OVER (PARTITION BY T3.name ORDER BY T3.years) AS rowNumber FROM ( SELECT DISTINCT name, STRFTIME('%Y', `date`) AS years FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.score = 100 ) AS T3 ) AS T4 GROUP BY T4.name, date(T4.years || '-01-01', '-' || (T4.rowNumber - 1) || ' years') HAVING COUNT(T4.years) = 4;