Вот так красивее и правильнее :)
select h.nhome, count(*), h1.fcount
from flats f
join homes h
on h.idhome = f.idhome
join (
select h.idhome, count(*) as fcount
from flats f
join homes h
on h.idhome = f.idhome
group by h.idhome, h.nhome
) h1
on h1.idhome = h.idhome
where f.floor = 1
group by h.idhome, h.nhome, h1.fcount