Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query Question

Status
Not open for further replies.

heprox

IS-IT--Management
Dec 16, 2002
178
US
I have this script for my database that creates both of temp tables correctly but errors out on the line, "or where a.sku_num not in
(select gm_sku2store.sku_num from gm_sku2store
where a.sku_num = gm_sku2store.sku_num);"

...I want it to query the two temp tables and come back with the correct records as well as reference another table for records that aren't there? Anyone?



create table &temp_table1 as
select gm_sku.sku_num, gm_itm.des1, gm_itm.vsn,
gm_itm.ve_cd, gm_itm.div_cd
from gm_sku, gm_itm, gm_inv_loc
where gm_sku.sku_num = gm_inv_loc.sku_num
and gm_sku.itm_cd = gm_itm.itm_cd
and gm_inv_loc.store_cd='0001'
group by gm_sku.sku_num, gm_itm.des1, gm_itm.vsn,
gm_itm.ve_cd, gm_itm.div_cd
having sum(gm_inv_loc.avail_qty) > 0;

create table &temp_table2 as
select sku_num
from gm_sku2store
group by sku_num
having sum(min_qty) < 0;

select a.sku_num, a.des1, a.vsn,
a.ve_cd, a.div_cd
from &temp_table1 a
where exists
(select b.sku_num from &temp_table2 b
where a.sku_num = b.sku_num)
or where a.sku_num not in
(select gm_sku2store.sku_num from gm_sku2store
where a.sku_num = gm_sku2store.sku_num);
 
where exists
(select b.sku_num from &temp_table2 b
where a.sku_num = b.sku_num)
or a.sku_num not in
(select gm_sku2store.sku_num from gm_sku2store
where a.sku_num = gm_sku2store.sku_num);

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
That was it, something so simple, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top