I have a project created by java code, and a database that has two tables (table1 and table2) looks like this:
-------table1--------
Name | Ref
__________|__________
A | 100
B | 200
__________|__________
and
-------table2--------
Name | Q
__________|__________
A | 12
B | 10
A | 14
__________|__________
I try create a SQL query to get this result:
Name | Ref | SUM(Q)
__________|_________|__________
A | 100 | 26
B | 200 | 10
__________|_________|__________
I wrote this query
query ="SELECT table1.Name,table1.Ref FROM table1 WHERE table1.Name=(SELECT table2.Name,SUM(table2.Q) FROM table2 GROUP BY table2.Name)";
but my code not working and I'm getting this error:
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::5.0.0 row column count mismatch
any suggestions to correct my query code?