Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> SQL Query
I hope this is the right place.
I'm using 8.1.7 on NT
I have 3 tables
INVENTORY_ITEMS
Item Number | Flag Code Value | Flag Code Value | Flag Code Value
Item X null null null Item Y null True true Item Z True nulltrue
I've searched a couple of SQL books, but did not see an immediate answer; I know that it is possible via pl/sql but would prefer a single statement.
I tried to create a couple of very simple scripts (as the real tables are a bit more complex), if someone can help
create table tmp_items (item_id number primary key, item_number
varchar2(10));
create table tmp_flags (flag_id number primary key, flag_code varchar2(10));
create table tmp_item_flags(item_id number, flag_id number);
insert into tmp_items values(1, 'ITEM A'); insert into tmp_items values(2, 'ITEM B'); insert into tmp_items values(3, 'ITEM C'); INSERT INTO TMP_FLAGS VALUES (10, 'FLAG A');INSERT INTO TMP_FLAGS VALUES (11, 'FLAG B'); INSERT INTO TMP_FLAGS VALUES (12, 'FLAG C');
INSERT INTO TMP_ITEM_FLAGS VALUES (2, 10); INSERT INTO TMP_ITEM_FLAGS VALUES (2, 11); INSERT INTO TMP_ITEM_FLAGS VALUES (3, 11);
I would like the query to return:
ITEM_NUMBER | FLAG A | FLAG B | FLAG C
ITEM A NULL NULL NULL ITEM B FLAG A FLAG B NULL ITEM C FLAG A NULLFLAG C TIA
![]() |
![]() |