-- 目前遇到几种情况 -------------------------------------------情况一---------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 情况一、先根据 TABLE_QTY 筛选 where status 条件后,根据五个主键做 group by ,取库存 sum ( qty ) 拿到结果集关联 INNER JOIN TABLE_B 、INNER JOIN TABLE_L 、INNER JOIN TABLE_S 。
-- 简写 flinkSql:
INSERT INTO SINK values(***) select qty.goodsqty from ( select sum(goodsqty) as goodsqty from TABLE_QTY where status =0 group by goodsid,sid,bid,lid,goodsstatusid ) qty INNER JOIN TABLE_B b on qty.bid = b.bid INNER JOIN TABLE_L l on qty.lid = b.lid INNER JOIN TABLE_S s on qty.sid = b.sid
-------------------------------------------情况二---------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 情况二、先根据 TABLE_QTY 筛选 where 条件后, 拿到结果集关联 INNER JOIN TABLE_B 、INNER JOIN TABLE_L 、INNER JOIN TABLE_S 。 最后再 根据五个主键做 group by ,取库存 sum ( qty ) -- 简写 flinkSql: INSERT INTO SINK values(***)
select sum(goodsqty) from TABLE_QTY ( select * from TABLE_QTY TABLE_QTY where status =0 ) qty INNER JOIN TABLE_B b on qty.bid = b.bid INNER JOIN TABLE_L l on qty.lid = b.lid INNER JOIN TABLE_S s on qty.sid = b.sid group by goodsid,sid,bid,lid,goodsstatusid
-------------------------------------------情况三---------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 情况三、先根据 TABLE_QTY 筛选 where status 条件, 拿到结果集关联 INNER JOIN TABLE_B 、INNER JOIN TABLE_L 、INNER JOIN TABLE_S 。 不再做 group by -- 简写 flinkSql: INSERT INTO SINK values(***)
select * from TABLE_QTY qty where status =0 INNER JOIN TABLE_B b on qty.bid = b.bid INNER JOIN TABLE_L l on qty.lid = b.lid INNER JOIN TABLE_S s on qty.sid = b.sid
-------------------------------------------情况四---------------------------------------------------------- ----------------------------------------------------------------------------------------------------------- 情况四、先根据 TABLE_QTY 不筛选 where status 条件, 拿到结果集关联 INNER JOIN TABLE_B 、INNER JOIN TABLE_L 、INNER JOIN TABLE_S 。 不再做 group by -- 简写 flinkSql: INSERT INTO SINK values(***) select * from TABLE_QTY qty INNER JOIN TABLE_B b on qty.bid = b.bid INNER JOIN TABLE_L l on qty.lid = b.lid INNER JOIN TABLE_S s on qty.sid = b.sid