一次編程實踐[ASP+MSSQL]

來源:互聯網
上載者:User
asp+|編程
本人工作單位是一家橡塑產品製造企業,05年2月單位領導要求我開發一個生產流程資料核對錶,用來稽核流程資料的準確性,其報表基本原理如下:

後續工序今日正品數 + 後續工序今日廢品數 = 本工序今日正品數 + 本工序今日留存數 - 本工序昨日留存數

瞭解了原理後馬上開工,第一次考慮用暫存資料表:


select distinct LEFT(productid, 4) + '00' as productid into #productid from yuancaiFlow_view
where productiondate = '2004-3-1'
and productid like '01____'
go
select a.productid,
       b.productname,
       isnull(hj.GoodQty, 0) as hj_good,
       isnull(hjtoday.qty, 0) as hj_today,
       isnull(hjyesterday.qty, 0) hj_yesterday,
       isnull(hj.GoodQty, 0) - isnull(hjtoday.qty, 0) + isnull(hjyesterday.qty, 0) - isnull(sx.GoodQty, 0) - isnull(sx.BadQty, 0) as hj_difference,
       isnull(sx.GoodQty, 0) as sx_good,
       isnull(sx.BadQty, 0) as sx_bad,
       isnull(sxtoday.qty, 0) as sx_today,
       isnull(sxyesterday.qty, 0) sx_yesterday,
       isnull(sx.GoodQty, 0) - isnull(sxtoday.qty, 0) + isnull(sxyesterday.qty, 0) - isnull(jt.GoodQty, 0) - isnull(jt.BadQty, 0) as sx_difference,
       isnull(jt.GoodQty, 0) as jt_good,
       isnull(jt.BadQty, 0) as jt_bad,
       isnull(jttoday.qty, 0) as jt_today,
       isnull(jtyesterday.qty, 0) jt_yesterday,
       isnull(jt.GoodQty, 0) - isnull(jttoday.qty, 0) + isnull(jtyesterday.qty, 0) - isnull(ph.GoodQty, 0) - isnull(ph.BadQty, 0) as jt_difference,
       isnull(ph.GoodQty, 0) as ph_good,
       isnull(ph.BadQty, 0) as ph_bad,
       isnull(phtoday.qty, 0) as ph_today,
       isnull(phyesterday.qty, 0) ph_yesterday,
       isnull(ph.GoodQty, 0) - isnull(phtoday.qty, 0) + isnull(phyesterday.qty, 0) - isnull(zj.GoodQty, 0) - isnull(zj.BadQty, 0) as ph_difference,
       isnull(zj.GoodQty, 0) as zj_good,
       isnull(zj.BadQty, 0) as zj_bad
   from #productid as a,
        finishedproduct as b,
        yuancaiFlow_view as hj,
        basflowsubsistence as hjtoday,
        basflowsubsistence as hjyesterday,
        yuancaiFlow_view as sx,
        basflowsubsistence as sxtoday,
        basflowsubsistence as sxyesterday,
        yuancaiFlow_view as jt,
        basflowsubsistence as jttoday,
        basflowsubsistence as jtyesterday,
        yuancaiFlow_view as ph,
        basflowsubsistence as phtoday,
        basflowsubsistence as phyesterday,
        yuancaiFlow_view as zj
   where a.productid = b.productid
   --hj
   and hj.productiondate = '2004-3-1'
   and left(a.productid, 4) *= left(hj.productid, 4)
   and hj.productid like '____06'  
   and left(a.productid, 4) + '06' *= hjtoday.productid
   and hjtoday.checkdate = '2004-3-1'
   and left(a.productid, 4) + '06' *= hjyesterday.productid
   and hjyesterday.checkdate = '2004-2-29'
   --sx
   and sx.productiondate = '2004-3-1'
   and left(a.productid, 4) *= left(sx.productid, 4)
   and sx.productid like '____08'  
   and left(a.productid, 4) + '08' *= sxtoday.productid
   and sxtoday.checkdate = '2004-3-1'
   and left(a.productid, 4) + '08' *= sxyesterday.productid
   and sxyesterday.checkdate = '2004-2-29'
   --jt
   and jt.productiondate = '2004-3-1'
   and left(a.productid, 4) *= left(jt.productid, 4)
   and jt.productid like '____07'  
   and left(a.productid, 4) + '07' *= jttoday.productid
   and jttoday.checkdate = '2004-3-1'
   and left(a.productid, 4) + '07' *= jtyesterday.productid
   and jtyesterday.checkdate = '2004-2-29'
   --ph
   and ph.productiondate = '2004-



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。