我很难过,想要一些指示。
我有一个表格,可以在多列中记录订单;
COL_A - Order ID
COL_B - Order line
COL_C - Log of activities done on order line, 2=order accepted, 950=item in stock
COL_D - Stock Check, uses arithmetic function to work out if item is in stock, takes COL_C and divides by 950 to zero decimal places. 0 = no, 1 = yes
COL_E - Order status
COL_F - Product code
保存订单然后在执行操作时更新日志,使用操作值累积值,因此操作日志值952表示订单已被接受&项目有货。 Col_D使用COL_C日志值来指示订购的商品是否有库存。这只是将日志值除以950以指示是否有库存。
只有当订单的所有订购商品都有库存时,我才需要查询返回订单和所有订单行。
实施例 数据表:
期望的结果:
答案 0 :(得分:0)
select
COL_A as "ORDER ID",
COL_B as "Line NO",
COL_C as "Action LOG",
COL_D as "IN stock",
COL_E as "Status",
COL_F as "Product"
where
COL_D = 1;
答案 1 :(得分:0)
SELECT
COL_A as "ORDER ID",
COL_B as "Line NO",
COL_C as "Action LOG",
COL_D as "IN stock",
COL_E as "Status",
COL_F as "Product"
FROM Table
WHERE COL_A IN
(SELECT COL_A FROM Table
GROUP BY COL_A
HAVING MIN(COL_D) <> 0)