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 = をcaseステートメントの最後に移動しました。

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 に答える