I have two tables in a database. One has a list of accounts with various datapoints by account (fix_cost_summary). The second table has all trades done by all accounts and the commissions associated with the trades (comm_table). I am trying to run a query to output all columns from fix_cost_summary and a sum of commissions by account from comm_table.
My subquery is causing an "Unknown Column" error. Please let me know if there is an error in my code.
SELECT
fix_cost_summary.*,
comm_table.Short_Name,
(SELECT SUM(Commissions)
FROM
comm_table
GROUP BY
comm_table.Short_Name)
FROM
fix_cost_summary,
comm_table
WHERE
fix_cost_summary.Short_Name = comm_table.Short_name
Short_Namevalues incomm_table, the subquery will return multiple results which will produceER_TOO_MANY_ROWS(albeit not the error cited by the OP).