Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 1026

Data Conversion issue

$
0
0

Hi Experts i write the following query

SELECT

 

 

max (T0.[DocNum]) as "S.O.#",

T1.U_JbNo as 'Job No.',

max(T0.[NumAtCard]) as "P.O.#",

Max (T0.[DocDate]) as "S.O.Date",

T1.[Shipdate] as "Ship Date",

MAX(t1.linestatus) as 'Status' ,MAX(T0.[CardCode]) as "V.Code",

MAX(T0.[CardName]) as "V.  Name",

Max(T1.[ItemCode]) as "Item Code",

max (T1.[Dscription]) as "Item Name",

MAX(T4.InvntryUom) as 'UOM',

T1.[Quantity] as "S.O. Qty",

T1.U_KGS as 'SO Qty Kgs',

 

 

isnull ((select sum (F.Quantity)from ODLN E Left join

DLN1 F on E.DocEntry = F.DocEntry where f.ItemCode = T1.ItemCode and T1.U_JbNo = F.U_JbNo),0) 'Del Qty',

 

isnull ((select sum(g.Quantity)from ORDN h Left Join

RDN1 g on h.DocEntry = g.DocEntry where g.U_JbNo = T1.U_JbNo ),0) 'Ret Qty',

 

isnull ((select sum(j.Quantity)from ORIN i Left Join

RIN1 j on j.DocEntry = i.DocEntry where j.U_JbNo = T1.U_JbNo ),0) 'CRN Qty',

 

T1.Quantity - isnull ((select sum (F.Quantity)from ODLN E Left join

DLN1 F on E.DocEntry = F.DocEntry where f.ItemCode = T1.ItemCode and T1.U_JbNo = F.U_JbNo),0)+ isnull ((select sum(g.Quantity)from ORDN h Left Join

RDN1 g on h.DocEntry = g.DocEntry where g.U_JbNo = T2.U_JbNo ),0)+isnull ((select sum(j.Quantity)from ORIN i Left Join

RIN1 j on j.DocEntry = i.DocEntry where j.U_JbNo = T1.U_JbNo ),0) 'Bal. Qty',

 

(T1.Quantity)-(T1.Quantity - isnull ((select sum (F.Quantity)from ODLN E Left join

DLN1 F on E.DocEntry = F.DocEntry where f.ItemCode = T1.ItemCode and T1.U_JbNo = F.U_JbNo),0)+ isnull ((select sum(g.Quantity)from ORDN h Left Join

RDN1 g on h.DocEntry = g.DocEntry where g.U_JbNo = T2.U_JbNo ),0) + isnull ((select sum(j.Quantity)from ORIN i Left Join

RIN1 j on j.DocEntry = i.DocEntry where j.U_JbNo = T1.U_JbNo ),0)) as 'Actual Qty Delivered',

 

max (t4.U_Cylsize) as "Cyl. Size",

max(t4.U_Cutolth )as "Cut of Length",

Max(t4.U_Rwidth) as "Film Size",

Max(t4.U_Prntmat) as "Print on",

Max(t4.U_Prntmic) as "Print Mic",

isnull(Max(t4.U_PGram),0) as "Print GSM",

Max(t4.U_Lmmat1) as "Lam-1 on",

Max(t4.U_LMmic1) as "Lam-1 Mic",

isnull(Max(t4.U_LmGram1),0) as "Lam1 GSM",

MAX(t4.U_Lmmat2) as "Lam-2 on",

MAX(t4.U_Lmmic2) as "Lam-2 Mic",

isnull(Max(t4.U_LmGram2),0) as "Lam2 GSM",

isnull(Max(t4.U_PGram),0) + isnull(Max(t4.U_LmGram1),0) + isnull(Max(t4.U_LmGram2),0) as 'Total GSM',

isnull(Max(t4.U_PGram),0)/nullif (isnull(Max(t4.U_PGram),0) + isnull(Max(t4.U_LmGram1),0) + isnull(Max(t4.U_LmGram2),0),0) * 100 as 'P Mat%' ,

isnull(Max(t4.U_LmGram1),0)/nullif (isnull(Max(t4.U_PGram),0) + isnull(Max(t4.U_LmGram1),0) + isnull(Max(t4.U_LmGram2),0),0) * 100 as 'Lm1 Mat%' ,

isnull(Max(t4.U_LmGram2),0)/nullif (isnull(Max(t4.U_PGram),0) + isnull(Max(t4.U_LmGram1),0) + isnull(Max(t4.U_LmGram2),0),0) * 100 as 'Lm2 Mat%' ,

Case MAX(T4.InvntryUom)

When 'PCS' then (isnull(Max(t4.U_PGram),0)/nullif (isnull(Max(t4.U_PGram),0) + isnull(Max(t4.U_LmGram1),0) + isnull(Max(t4.U_LmGram2),0),0)) * convert(numeric,(Isnull(T1.U_KGS,0)))

When 'KGS' then  (isnull(Max(t4.U_PGram),0)/nullif (isnull(Max(t4.U_PGram),0) + isnull(Max(t4.U_LmGram1),0) + isnull(Max(t4.U_LmGram2),0),0)) * T1.[Quantity]

Else 'Others'

End 'P Mat Req',

MAX(T0.comments) as "Remarks",

MAX(t4.U_SlitSize) as "Width",

MAX(T1.U_Kgs) as 'Pcs in Kgs'

 

 

 

 

 

 

FROM

ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry

left outer join DLN1 T2

on T1.U_JbNo = T2.U_JbNo

left outer join odln t3 on t2.docentry=t3.docentry

left outer join oitm t4 on t1.itemcode=t4.itemcode

LEFT join RDN1 T5 on  T1.U_JbNo = T5.U_JbNo

left outer join ORDN T6 on T6.DocEntry = T5.DocEntry

Left Join NNM1 T7 on T0.Series = T7.Series

Left Join INV1 T11 on T11.U_JbNo = T1.U_JbNo

Left Join OINV T12 on T11.DocEntry = T12.DocEntry

Left Join RIN1 T13 on T13.U_JbNo = T1.U_JbNo

 

 

Where T0.Series <> '160' and T0.DocDate > '12/02/2015'

group  by

T1.U_JbNo,T1.[Shipdate],T5.U_jbNo, T2.U_JbNo,T1.[Quantity],T1.ItemCode,T0.Docnum,T1.U_KGS

 

 

 

 

order by

T0.DocNum

 

When it runs it shows the following error

 

Msg 8114, Level 16, State 5, Line 1

Error converting data type varchar to numeric.

Warning: Null value is eliminated by an aggregate or other SET operation.

 

Can anyone guide me where am i missing in this query

 

Ragards

Jamil


Viewing all articles
Browse latest Browse all 1026

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>