Sql query help adding calculated field
Posted on 2011-03-18
I have a sql query that is working well but I need to add another calculated field to and cant seem to get it to work
My Current Query
SELECT OIBT.ItemCode, OIBT.BatchNum, POR1.ShipDate, POR1.OpenQty, OIBT.InDate, OPOR.CardCode, OPOR.CardName,
DATEDIFF(day, isnull(POR1.U_SIF_VENDPROM, POR1.ShipDate),OIBT.InDate) AS dayslate
FROM OIBT INNER JOIN
OPDN ON OIBT.BaseType = OPDN.ObjType AND OIBT.BaseNum = OPDN.DocNum INNER JOIN
PDN1 ON OPDN.DocEntry = PDN1.DocEntry INNER JOIN
OPOR INNER JOIN
POR1 ON OPOR.DocEntry = POR1.DocEntry ON PDN1.BaseType = OPOR.ObjType AND PDN1.BaseEntry = OPOR.DocEntry AND
PDN1.BaseLine = POR1.LineNum
WHERE (OPOR.U_SIF_PO_Sample = 'Y')
I would like to be able to add another field based on what is populated AS dayslate.
if dayslate (the three following conditions)
< 1 = 'On Time / Early'
< 8 = 'Late 1-7 days'
> 7 = 'Late >7 days'