cancel
Showing results for 
Search instead for 
Did you mean: 

Formatted Search Query CASE STATEMENT

0 Kudos

Hi ALL

I have a query which loads a value on gate pass no entered in GRPO.

Select Case when pdn1.itemcode='RA0001' then (SELECT DATA FROM A TABLE A)

when pdn1.itemcode='CN0002' then (SELECT DATA FROM A TABLE B) end

from pdn1 t0,opdn t1 where t0.docentry=t1.docentry and U_GP=$[OPDN.U_GP]

I am getting this error

1). [Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "pdn1.itemcode" could not be bound. 2). [Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "pdn1.itemcode" could not be bound. 3). [Microsoft][SQL Server Native Client 11.0][SQL Server]The multi-part identifier "opdn.u_gp" could not be bound. 4). [Microsoft][SQL Server Native Client 11.0][SQL Server]Statement 'Blanket Agreement' (OOAT) (s) could not be prepared.

Original qry

SELECT case when pdn1.itemcode='RA0001' then (Select (COALESCE( U_WGH,0)-(COALESCE(u_FGBAGS,0)+COALESCE(U_EGBAGS,0)+COALESCE(U_Party,0)))/1000 from [@I_UNLOAD] where U_GP= T0.[U_GP] ) when pdn1.itemcode='CN0002' then (Select COALESCE(U_Diff,0) from [@I_WGHBRG] where U_GP= T0.[U_GP] ) end from pdn1 t0,opdn t1 where t0.docentry=t1.docentry and U_GP=$[OPDN.U_GP]

THanks and regards

Sheetal

Accepted Solutions (1)

Accepted Solutions (1)

kothandaraman_nagarajan
Active Contributor

Hi,

Try this,

SELECT case when T0.itemcode='RA0001' then (Select (COALESCE( U_WGH,0)-(COALESCE(u_FGBAGS,0)+COALESCE(U_EGBAGS,0)+COALESCE(U_Party,0)))/1000 from [@I_UNLOAD] where U_GP= T0.[U_GP] ) when T0.itemcode='CN0002' then (Select COALESCE(U_Diff,0) from [@I_WGHBRG] where U_GP= T0.[U_GP] ) end from pdn1 t0,opdn t1 where t0.docentry=t1.docentry and T1.U_GP=$[OPDN.U_GP]

Regards,

Nagarajan

0 Kudos

Thank You Sir

i changed the query as you said now getting this err

1). [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'U_GP'.

2). [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'U_GP'.

3). [Microsoft][SQL Server Native Client 11.0][SQL Server]Statement '' (CRD2) (s) could not be prepared.

Answers (1)

Answers (1)

0 Kudos

Thank You Sir

i changed the query as you said now getting this err

1). [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'U_GP'.

2). [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'U_GP'.

3). [Microsoft][SQL Server Native Client 11.0][SQL Server]Statement '' (CRD2) (s) could not be prepared.