Hello,
kind of new to DB2 SQL
I am trying to write a simple query but have a bunch of errors when do a "Where Statement"
so I was thinking in doing aliases for the fields but that does not seem to work,
Here is a snipet of my query
The code above works well but when I try this
it does not work so I was since I have the
in the select statement I wanted to do this
but that did not work either
any help is appreciated!!!
kind of new to DB2 SQL
I am trying to write a simple query but have a bunch of errors when do a "Where Statement"
so I was thinking in doing aliases for the fields but that does not seem to work,
Here is a snipet of my query
Code:
SELECT
DAVLOGIC.MOMASTLF.ORDNO,
EDGARQRY.MOIP.ITNBR,
EDGARQRY.MOIP.TRQTY01,
DAVLOGIC.MOROUTX3.OPSEQ,
DAVLOGIC.MOROUTX3.TQCTD,
EDGARQRY.COMPPRDREW.LTRQTY01,
EDGARQRY.COMPPRDREW.LRWKQT01,
DAVLOGIC.MOMASTLF.ORQTY,
DAVLOGIC.MOMASTLF.QTDEV,
Case when DAVLOGIC.MOMASTLF.OSTAT='45' then 'Closed' else 'Open' end AS Status,
DAVLOGIC.MOROUTX3.DPTNO,
DAVLOGIC.MOMASTLF.FITEM,
DAVLOGIC.MOMASTLF.FDESC,
DAVLOGIC.MOMASTLF.QTYRC,
DAVLOGIC.MOROUTX3.TQCTD - DAVLOGIC.MOMASTLF.QTYRC AS Difference,
DAVLOGIC.MOROUTX3.OPDSC,
DAVLOGIC.MOROUTX3.TQCTD + EDGARQRY.COMPPRDREW.LRWKQT01 + DAVLOGIC.MOROUTX3.SCRAP AS MoldPlusReworkScrp,
DAVLOGIC.MOROUTX3.SCRAP,
DAVLOGIC.MOMASTLF.QTYRC - EDGARQRY.MOIP.TRQTY01 AS InsrtvsQtyRc,
(DAVLOGIC.MOMASTLF.QTYRC - EDGARQRY.MOIP.TRQTY01)/EDGARQRY.MOIP.TRQTY01 AS prcntdiff,
DAVLOGIC.MOMASTLF.ASTDT
FROM DAVLOGIC.MOMASTLF
LEFT OUTER JOIN EDGARQRY.MOIP ON DAVLOGIC.MOMASTLF.ORDNO = EDGARQRY.MOIP.ORDNO
LEFT OUTER JOIN DAVLOGIC.MOROUTX3 ON EDGARQRY.MOIP.ORDNO = DAVLOGIC.MOROUTX3.ORDNO
LEFT OUTER JOIN EDGARQRY.COMPPRDREW ON DAVLOGIC.MOROUTX3.ORDNO = EDGARQRY.COMPPRDREW.LORD AND DAVLOGIC.MOROUTX3.OPSEQ = EDGARQRY.COMPPRDREW.LOPSEQ
The code above works well but when I try this
Code:
Where DAVLOGIC.MOMASTLF.QTYRC - EDGARQRY.MOIP.TRQTY01 / DAVLOGIC.MOMASTLF.QTYRC >.05
it does not work so I was since I have the
Code:
(DAVLOGIC.MOMASTLF.QTYRC - EDGARQRY.MOIP.TRQTY01)/EDGARQRY.MOIP.TRQTY01 AS prcntdiff
Code:
(DAVLOGIC.MOMASTLF.QTYRC - EDGARQRY.MOIP.TRQTY01)/EDGARQRY.MOIP.TRQTY01 AS prcntdiff,
prcntdiff
FROM DAVLOGIC.MOMASTLF
LEFT OUTER JOIN EDGARQRY.MOIP ON DAVLOGIC.MOMASTLF.ORDNO = EDGARQRY.MOIP.ORDNO
LEFT OUTER JOIN DAVLOGIC.MOROUTX3 ON EDGARQRY.MOIP.ORDNO = DAVLOGIC.MOROUTX3.ORDNO
LEFT OUTER JOIN EDGARQRY.COMPPRDREW ON DAVLOGIC.MOROUTX3.ORDNO = EDGARQRY.COMPPRDREW.LORD AND DAVLOGIC.MOROUTX3.OPSEQ = EDGARQRY.COMPPRDREW.LOPSEQ
Where prcntdiff > .05
any help is appreciated!!!