SQL Query Challenge

Using two tables (Countries and Locales), write an SQL query to retrieve country names lacking exactly one default language.

Countries:

cid  ccode  cname
1    USA    UnitedStates
2    GBR    GreatBritain

Locales:

lid  ccode  lang  def_flag
101  USA    en    true
102  GBR    en    false

hey, i wonder if joining and grouping by ccode then filtering where count(def_flag=true) != 1 might do the trick? anyone tried something similar? what r your thoughts

hey, try sum(case when def_flag=‘true’ then 1 else 0 end) in having clause. it filters out those with exactly one default lang. works for me, not sure if it’s the best but its neat enough