Q:

subquery Count() - Column must appear in the GROUP BY clause

I just wanted to know, why a subquery returned more than one value, so I made this query:
SELECT id, 
    (SELECT Count(tags[i]) 
        FROM generate_subscripts(tags, 1) AS i 
        WHERE tags[i]='oneway') as oneway_string 

    FROM planet_osm_ways 
    WHERE 'oneway' = ANY(tags) 
    HAVING 
        (SELECT Count(tags[i]) 
            FROM generate_subscripts(tags, 1) AS i 
            WHERE tags[i]='oneway')  > 1

which should find all occurences of 'oneway' in tags array and count them.
[42803] ERROR: column "planet_osm_ways.id" must appear in the GROUP BY clause 
               or be used in an aggregate function Position: 8

A:

You should change HAVING to WHERE as there are no groups on which you could apply HAVING filter, instead you want to use WHERE filter which applies to each row.
SELECT id, 
(SELECT Count(tags[i]) 
    FROM generate_subscripts(tags, 1) AS i 
    WHERE tags[i]='oneway') as oneway_string 

FROM planet_osm_ways 
WHERE 'oneway' = ANY(tags) 
    AND 
    (SELECT Count(tags[i]) 
        FROM generate_subscripts(tags, 1) AS i 
        WHERE tags[i]='oneway')  > 1

