Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
eljapo4
Posting Yak Master
100 Posts |
Posted - 2011-01-05 : 08:18:34
|
hi can anyone help me correct the following code?CASE WHEN fdCostRole.invstdoneUM <> inUserDefinedLi.PrimQtyUM THEN ( ELSE CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.ToUM THEN (inUserDefinedLi.PrimQty * bcConvFactor.ToFactor) ELSE CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.FromUM THEN (inUserDefinedLi.PrimQty / bcConvFactor.ToFactor) ELSE inUserDefinedLi.PrimQty END )END AS TEST Should I be using an IF Statement instead? |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-01-05 : 08:25:53
|
What do you want to do for this condition fdCostRole.invstdoneUM <> inUserDefinedLi.PrimQtyUM ?MadhivananFailing to plan is Planning to fail |
 |
|
eljapo4
Posting Yak Master
100 Posts |
Posted - 2011-01-05 : 08:32:16
|
I want it to step into the brackets and determine which logic to apply depending on which UM the inUserDefinedLi.PrimQtyUM matches |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-01-05 : 08:45:10
|
Try thisCASE WHEN fdCostRole.invstdoneUM <> inUserDefinedLi.PrimQtyUM THEN (CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.ToUM THEN (inUserDefinedLi.PrimQty * bcConvFactor.ToFactor) ELSE CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.FromUM THEN (inUserDefinedLi.PrimQty / bcConvFactor.ToFactor) ELSE inUserDefinedLi.PrimQty END )END AS TEST MadhivananFailing to plan is Planning to fail |
 |
|
eljapo4
Posting Yak Master
100 Posts |
Posted - 2011-01-05 : 09:06:13
|
I'm getting an 'incorrect syntax near ')'. error at this bit of codeCASE WHEN fdCostRole.invstdoneUM <> inUserDefinedLi.PrimQtyUM THEN (CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.ToUM THEN (inUserDefinedLi.PrimQty * bcConvFactor.ToFactor) ELSE CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.FromUM THEN (inUserDefinedLi.PrimQty / bcConvFactor.ToFactor) ELSE inUserDefinedLi.PrimQty END ) --hereEND AS TEST |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-01-05 : 09:39:55
|
[code]CASE WHEN fdCostRole.invstdoneUM <> inUserDefinedLi.PrimQtyUM THEN (CASE WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.ToUM THEN (inUserDefinedLi.PrimQty * bcConvFactor.ToFactor) WHEN inUserDefinedLi.PrimQtyUM = bcConvFactor.FromUM THEN (inUserDefinedLi.PrimQty / bcConvFactor.ToFactor) ELSE inUserDefinedLi.PrimQty END ) --hereEND AS TEST[/code]MadhivananFailing to plan is Planning to fail |
 |
|
eljapo4
Posting Yak Master
100 Posts |
Posted - 2011-01-05 : 11:49:29
|
Thank you for your help on this Madhivanan |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-01-06 : 04:33:27
|
quote: Originally posted by eljapo4 Thank you for your help on this Madhivanan
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|