I have this table:
BANK – BRANCH_NAME – ADDRESS – DISTRICT – CITY – PHONE – FAX – OPENNING DATE
How do I bring branches on a city basis?
What I expect is a city knows how many branches it has.
Advertisement
Answer
From the comments:
what I expect is a city knows how many branches it has
You can use aggregation:
select city, count(*) no_branches from mytable group by city
If (city, branch)
tuples are not unique in the table, then:
select city, count(distinct branch) no_branches from mytable group by city