I have two tables as below with three keys and sub table has multiple records on key no31:
TableA: no1,no2,no31
no1,no2,n032
TableB: no1,no2,n031,file311
no1,no2,n031,file312
no1,no2,n031,file313
no1,no2,n032,file321
no1,no2,n032,file322
I want to select result as below to count records on sub table with same three keys
result: no1, no2, no31, 3
no1, no2, no32, 2
I tried SQL as below, but I got error ORA-00904: "A"."ARTICLE_NO": "%s: invalid identifier", what can I do?
SELECT A.no1, A.no2, A.no3, P.PHOTO_COUNT
FROM TableA A,
(SELECT COUNT(*) AS PHOTO_COUNT
FROM TableB
WHERE no1 = 'param1' AND no2 = 'param2' AND no3 = A.no3) P
WHERE A.no1 = 'param1' AND A.no2 = 'param2'
