fjtello / SQL-C-sharp

Common programming and coding tips and howtos
0 stars 0 forks source link

SQL syntax [#cte] #6

Open fjtello opened 7 years ago

fjtello commented 7 years ago

; with px(idprovincia, provincia) as (select p.idprovincia, p.provincia from provincias p where provincia like '%ia%') select count(m.idmunicipio), px.provincia
from municipios m left join px on (px.idprovincia = m.idProvincia) group by px.provincia order by px.provincia;