I need to use if else statement in select statement ..I created SP and tried following
ALTER PROCEDURE [PR].[SPJ_PurchaseOrderDShipmentD]
@ParentDocCode varchar(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT distinct D.DocCode, D.FKFYCode, D.DocPrefix, D.DocNo, D.DocDate, D.FkItemCode,
D.FkItemName,D.FkItemName,
ISNULL((select InventoryUOMCode from MM.ITMIV where FkItemCode=D.FkItemCode),'0') as UOMCode,
ISNULL((select InventoryUOM from MM.ITMIV where FkItemCode=D.FkItemCode),'NA') as UOMName,
CAST(D.qty + (ISNULL((sELECT sUM(qty) FROM PR.PMDTL WHERE FkItemCode=D.FkItemCode AND ParentDocCode=D.DOCCODE),0)) AS Decimal(18,2)) as TotalPOQty,
CAST(ISNULL((sELECT sUM(QTY) FROM PR.PSDTL WHERE FkItemCode=D.FkItemCode AND ParentDocCode=D.DocCode ),0) AS Decimal(18,2)) PreviousIssuedQty,
CAST( Qty + (ISNULL((sELECT sUM(qty) FROM PR.PMDTL WHERE FkItemCode=D.FkItemCode AND ParentDocCode=D.DocCode),0)) - (
ISNULL((sELECT sUM(QTY) FROM PR.PSDTL WHERE FkItemCode=D.FkItemCode AND ParentDocCode=D.DocCode ) ,0)) AS Decimal(18,2))
as Qty,0 as NextBalanceQty ,
case when P.Factor1=' '
then 0
else P.Factor1 as BrookerageAmt
from pr.PODTL P where FkItemCode=D.FkItemCode and DocCode=@ParentDocCode)
FROM
PR.POHDR H,PR.PODAC D
where D.DocCode=@ParentDocCode and d.DocCode = h.DocCode AND
Qty >0
and H.Status='Y' and D.Status='Y'
END
but getting an error pls help me out
any help appreciable
regards,
Shivani