计算SKU并返回QTY <Full QTY?

时间:2019-04-09 11:26:18

标签: sql oracle

我试图返回在子查询中计数为“ SKU_ID”大于1的行。

我面临的问题是当我独立运行子查询时,它会按预期返回行。但是,当我在where子句中使用时,出现以下错误:

  

ORA-01722:无效的号码   01722。

     

*原因:指定的数字无效。

     

*操作:指定一个有效数字。00000-“无效数字”

我尝试了以下方法...

SELECT inventory.sku_id, inventory.location_id, inventory.qty_on_hand, inventory.tag_id, inventory.full_pallet, sku_config.ratio_1_to_2 as "FULL QTY"
FROM inventory
                JOIN sku_sku_config ON inventory.sku_id = sku_sku_config.sku_id
                JOIN sku_config ON sku_sku_config.config_id = sku_config.config_id
WHERE inventory.sku_id in 
    (SELECT count(*)
                     FROM inventory
                     JOIN sku_sku_config ON inventory.sku_id = sku_sku_config.sku_id
                     JOIN sku_config ON sku_sku_config.config_id = sku_config.config_id
                     WHERE zone_1 NOT LIKE 'PROD' AND lock_status = 'UnLocked' AND full_pallet = 'N'
                     GROUP BY inventory.sku_id
                     HAVING count(*) >= 1)

1 个答案:

答案 0 :(得分:0)

我假设您想将 private List<Itype> Helper(IType type){ new List<type> someObject = new ArrayList<type>(); return someObject; } sku_id进行比较,而不是进行计数。所以:

sku_id

请注意,我根据问题的描述将比较更改为WHERE inventory.sku_id in (SELECT i2.sku_id FROM inventory i2 JOIN sku_sku_config ssc ON i2.sku_id = ssc.sku_id JOIN sku_config sc ON ssc.config_id = sc.config_id WHERE zone_1 NOT LIKE 'PROD' AND lock_status = 'UnLocked' AND full_pallet = 'N' GROUP BY i2.sku_id HAVING count(*) > 1 ) ,而不是> 1