I have a query that works like:
select table_one.x, sum(table_one.y)
(select foo from table_two where table_one.x = table_two.x) as item_description
from table_one
inner join table_two
on table_one.x = table_two.x
-- where table_2 row has various attributes
group by table_one.x
The grouping means I need a sub-select to access foo from table two. Now if I want to select a second column from table two, is there any way to access this without a second sub-select?
Database is DB2.
EDIT: join is many to one, ie think of table_one as orders and table_b as containing information for the item.