November 10, 2010 at 12:00 am
i have a result set
LedgerId, ProfitAndLoss
46 -3000.00
49 -7000.00
45 15000.00
I want Result Set As
LedgerId, ProfitAndLoss Result
46 -3000.00 Credit
49 -7000.00 Credit
45 15000.00 Debit
Please help me ProfitAndLoss Is a Decimal field and we have to separated by minus value
November 10, 2010 at 1:14 am
lax.rawat07 (11/10/2010)
i have a result setLedgerId, ProfitAndLoss
46 -3000.00
49 -7000.00
45 15000.00
I want Result Set As
LedgerId, ProfitAndLoss Result
46 -3000.00 Credit
49 -7000.00 Credit
45 15000.00 Debit
Please help me ProfitAndLoss Is a Decimal field and we have to separated by minus value
you can try using your 3rd column as a computed column.
if Profitandloss < 0 then 'Credit' ELSE 'Debit'
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
November 10, 2010 at 1:16 am
lax.rawat07 (11/10/2010)
i have a result setLedgerId, ProfitAndLoss
46 -3000.00
49 -7000.00
45 15000.00
I want Result Set As
LedgerId, ProfitAndLoss Result
46 -3000.00 Credit
49 -7000.00 Credit
45 15000.00 Debit
Please help me ProfitAndLoss Is a Decimal field and we have to separated by minus value
You can set this extra field with a case statement in your SELECT query as such:
SELECT LEDGERID, PROFITANDLOSS, RESULT =
CASE WHEN PROFITANDLOSS <= 0
THEN CREDIT
ELSE DEBIT
END
FROM MYTABLE
OR, you can add a calculated field to your underlying table.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply