I have Table:
stations (staion , phone , address)
AND
members (username , password , fullname , station)
I want to Station List , count username . So I wrote this query.
SELECT
stations.station as st,
(
SELECT COUNT(username)
FROM members
WHERE members.station = stations.station
) as co
FROM stations
GROUP BY stations.station
ORDER BY stations.station
It alerts (Error) :
'ERROR: subquery uses ungrouped column "stations.station" from outer query'
Please help me to get right data with PostgreSQL.