Can Derby handle scalar subqueries in SELECT clause?

285 views Asked by At

I'm having trouble getting my query working. Could someone cast an experienced eye on it please? The table structure is simple (2 one-to-many relationships). The query is trying to work out for each sign, how many contributions there are at each unique "PositionLocation".

Sign <- Signifier (f_key sign_oid) <- Contribution (f_key signifier_oid)

I'm getting the following error:

Error: An ON clause associated with a JOIN operator is not valid.
SQLState:  42972
ErrorCode: -1

My query is:

select s.NAME, c.POSITIONLOCATION, count(*) as num_per_locn,
(
    select count(*) from APP.CONTRIBUTION c2
    inner join APP.SIGNIFIER si2 on si2.OID = c2.SIGNIFIER_OID
    inner join APP.SIGN s2 on s2.OID = si2.SIGN_OID
    and  s2.OID = s.OID
) as num_per_sign
from APP.CONTRIBUTION c
inner join APP.SIGNIFIER si on si.OID = c.SIGNIFIER_OID
inner join APP.SIGN s on s.OID = si.SIGN_OID
group by s.NAME, c.POSITIONLOCATION
0

There are 0 answers