I want to show this table where trading_area and reporting_unit are shown in separate columns for each id_num and name_item.
| id_num | name_item | trading_area | reporting_unit |
|---|---|---|---|
| 1001 | YC | Washington | BOA |
| 1002 | NO | Utah | BCG |
| 1001 | GO | Arizona | NYP |
I'm using the following query:
SELECT item.id_number, item.name_item, inf.info_value
FROM traded_item item, item_info inf, item_info_types typ
WHERE item.id_number = inf.item_id
AND inf.info_type_id = typ.type_id
AND typ.type_id IN (20005, 20001) ---trading_area, reporting_unit
ORDER BY name
However, this shows me the following table:
| id_num | name_item | info_value |
|---|---|---|
| 1001 | YC | Washington |
| 1002 | NO | Utah |
| 1001 | GO | Arizona |
| 1001 | YC | BOA |
| 1002 | NO | BCG |
| 1001 | GO | NYP |
