Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    54

    Question Unanswered: 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);

  2. #2
    Join Date
    Nov 2002
    Posts
    272
    You can only have 'where' once. So instead of 'or where' just use 'or'.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •