{"id":8641,"date":"2022-08-19T08:36:32","date_gmt":"2022-08-19T00:36:32","guid":{"rendered":"https:\/\/www.hefeiyu.com\/?p=8641"},"modified":"2022-08-19T08:42:11","modified_gmt":"2022-08-19T00:42:11","slug":"sql%e9%80%92%e5%bd%92%e5%b1%95bom","status":"publish","type":"post","link":"https:\/\/www.hefeiyu.com\/?p=8641","title":{"rendered":"sql\u9012\u5f52\u5c55BOM"},"content":{"rendered":"<p>\u672c\u4eba\u6709\u5199\u53e6\u4e00\u4e2aTIPTOP\u7248\u672c<\/p>\n<h1 class=\"article-title\"><a href=\"https:\/\/www.hefeiyu.com\/?p=1224\">TIPTOP BOM\u5c55\u5c3e\u9636SQL<\/a><\/h1>\n<p>\u4ee5\u4e0b\u6765\u81ea\u7f51\u7edc\uff1a<\/p>\n<p>TIPTOP\u7248\u672c<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"sql\">WITH t AS ( SELECT SYS_CONNECT_BY_PATH(a.bmb01,'|')||'|'||a.bmb03||'|' as path\r\n,SYS_CONNECT_BY_PATH(a.bmb06,'|')||'|' as qty_path,bmb06,bmb10\r\nFROM bmb_file a\r\nSTART WITH a.bmb01 = :ITEM\r\nAND a.bmb04 &lt;= sysdate AND (a.bmb05 &gt; sysdate or a.bmb05 is null)\r\nCONNECT BY a.bmb01 = PRIOR a.bmb03 AND a.bmb04 &lt;= sysdate AND (a.bmb05 &gt; sysdate or a.bmb05 is null) )\r\n\r\nSELECT G_CODE_CP,a.ima02 aima02,a.ima021 aima021,G_CODE_LJ,b.ima02 bima02,b.ima021 bima021,bmb10,SUM(DEC_CM) AS DEC_CM\r\nFROM (SELECT SUBSTR(path,2,INSTR(path,'|',1,2)-INSTR(path,'|',1,1)-1) as G_CODE_CP\r\n,SUBSTR(path,INSTR(path,'|',-1,2)+1,INSTR(path,'|',-1,1)-INSTR(path,'|',-1,2)-1) as G_CODE_LJ\r\n,(SELECT EXP(SUM(LN(SUBSTR(qty_path,INSTR(qty_path,'|',1,rn)+1,INSTR(qty_path,'|',1,rn+1)-INSTR(qty_path,'|',1,rn)-1))))\r\nFROM (SELECT ROWNUM RN FROM DUAL CONNECT BY ROWNUM&lt;=100)\r\nWHERE SUBSTR(qty_path,INSTR(qty_path,'|',1,rn)+1,INSTR(qty_path,'|',1,rn+1)-INSTR(qty_path,'|',1,rn)-1) IS NOT NULL\r\n) AS DEC_CM,bmb10  FROM t )\r\nLEFT OUTER JOIN ima_file a on a.ima01 =G_CODE_CP\r\nLEFT OUTER JOIN ima_file b on b.ima01 =G_CODE_LJ\r\nGROUP BY G_CODE_CP,a.ima02,a.ima021,b.ima02,b.ima021,bmb10,G_CODE_LJ;\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>T100\u7248\u672c<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"sql\">WITH t AS ( SELECT SYS_CONNECT_BY_PATH(a.bmba001,'|')||'|'||a.bmba003||'|' as path\r\n,SYS_CONNECT_BY_PATH((a.bmba011\/a.bmba012),'|')||'|' as qty_path,bmba011,bmba010\r\nFROM bmba_t a\r\nSTART WITH a.bmba001 =:ITEM and a.bmbaent=:ENT and bmbasite=:SITE\r\nAND a.bmba005 &lt;= sysdate AND (a.bmba006 &gt; sysdate or a.bmba006 is null)\r\nCONNECT BY a.bmba001 = PRIOR a.bmba003 AND a.bmba005 &lt;= sysdate AND (a.bmba006 &gt; sysdate or a.bmba006 is null) )\r\n\r\nSELECT G_CODE_CP,aa.imaal003,aa.imaal004,G_CODE_LJ,bb.imaal003,bb.imaal004,bmba010,SUM(DEC_CM) AS DEC_CM\r\nFROM (SELECT SUBSTR(path,2,INSTR(path,'|',1,2)-INSTR(path,'|',1,1)-1) as G_CODE_CP\r\n,SUBSTR(path,INSTR(path,'|',-1,2)+1,INSTR(path,'|',-1,1)-INSTR(path,'|',-1,2)-1) as G_CODE_LJ\r\n,(SELECT EXP(SUM(LN(SUBSTR(qty_path,INSTR(qty_path,'|',1,rn)+1,INSTR(qty_path,'|',1,rn+1)-INSTR(qty_path,'|',1,rn)-1))))\r\nFROM (SELECT ROWNUM RN FROM DUAL CONNECT BY ROWNUM&lt;=100)\r\nWHERE SUBSTR(qty_path,INSTR(qty_path,'|',1,rn)+1,INSTR(qty_path,'|',1,rn+1)-INSTR(qty_path,'|',1,rn)-1) IS NOT NULL\r\n) AS DEC_CM,bmba010  FROM t )\r\nleft outer join imaal_t aa on aa.imaalent=:ENT and aa.imaal001=G_CODE_CP and aa.imaal002='zh_CN'\r\nleft outer join imaal_t bb on bb.imaalent=:ENT and bb.imaal001=G_CODE_LJ and bb.imaal002='zh_CN'\r\nGROUP BY G_CODE_CP,aa.imaal003,aa.imaal004,bb.imaal003,bb.imaal004,bmba010,G_CODE_LJ;\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.hefeiyu.com\">\u8d6b\u975e\u57df<\/a> &raquo; <a href=\"https:\/\/www.hefeiyu.com\/?p=8641\">sql\u9012\u5f52\u5c55BOM<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u672c\u4eba\u6709\u5199\u53e6\u4e00\u4e2aTIPTOP\u7248\u672c TIPTOP BOM\u5c55\u5c3e\u9636SQL \u4ee5\u4e0b\u6765\u81ea\u7f51\u7edc\uff1a TIPTOP\u7248\u672c WITH t AS ( SELECT SYS_CONNECT_BY_PATH(a.bmb01,&#8217;|&#8217;)||&#8217;|&#8217;||a.bmb03||&#8217;|&#8217; as p [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[490,26],"tags":[437,1074,169],"class_list":["post-8641","post","type-post","status-publish","format-standard","hentry","category-490","category-4gl","tag-bmb","tag-connect","tag-path"],"_links":{"self":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/8641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8641"}],"version-history":[{"count":2,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/8641\/revisions"}],"predecessor-version":[{"id":8644,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=\/wp\/v2\/posts\/8641\/revisions\/8644"}],"wp:attachment":[{"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hefeiyu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}