If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Query Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-03, 16:41
heprox heprox is offline
Registered User
 
Join Date: Oct 2003
Posts: 54
Question SQL Query Question

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);
Reply With Quote
  #2 (permalink)  
Old 11-18-03, 05:46
ivon ivon is offline
Registered User
 
Join Date: Nov 2002
Posts: 272
You can only have 'where' once. So instead of 'or where' just use 'or'.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On