0

我的存储过程如下所示,

select T.TranNo,(Select Accountname from Accountable where AccountCode =T.tranAccountCode) particulars,TransactionType = case T.cate
when 'f' then 'Cash Voucher'
when 'h' then 'cash receipt'
when 'n' then 'cash receipt'
when 'o' then 'cash sale'
else 'unknowen'
end,
case when (T.TranAmount<0) then (T.TransAmount)*(-1)
End AS Credit,
case when (T.TranAmount>0) then (T.TransAmount)
end as Debit
from TranTable T where (T.TransAccountCode='1234') and (T.cate='k')

语法到底是什么……?

4

1 回答 1

1

我将 移至TransactionType = 案例陈述的末尾。

select T.TranNo,(Select Accountname from Accountable where AccountCode =T.tranAccountCode) particulars, 
  case T.cate
    when 'f' then 'Cash Voucher'
    when 'h' then 'cash receipt'
    when 'n' then 'cash receipt'
    when 'o' then 'cash sale'
    else 'unknowen'
  end as TransactionType,
  case 
   when (T.TranAmount<0) then (T.TransAmount)*(-1)
  End AS Credit,
  case when (T.TranAmount>0) then (T.TransAmount)
  end as Debit
from TranTable T where (T.TransAccountCode='1234') and (T.cate='k')
于 2012-07-04T17:24:48.257 回答