Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Result Set Rate Topic Display Mode Topic Options
Author
 Message
 Posted Wednesday, November 10, 2010 12:00 AM
 Forum Newbie Group: General Forum Members Last Login: Tuesday, November 09, 2010 11:55 PM Points: 1, Visits: 0
 i have a result setLedgerId, ProfitAndLoss46 -3000.0049 -7000.0045 15000.00I want Result Set AsLedgerId, ProfitAndLoss Result46 -3000.00 Credit49 -7000.00 Credit45 15000.00 Debit Please help me ProfitAndLoss Is a Decimal field and we have to separated by minus value
Post #1018387
 Posted Wednesday, November 10, 2010 1:14 AM
 SSCommitted Group: General Forum Members Last Login: Monday, September 30, 2013 12:48 AM Points: 1,896, Visits: 2,736
 lax.rawat07 (11/10/2010)i have a result setLedgerId, ProfitAndLoss46 -3000.0049 -7000.0045 15000.00I want Result Set AsLedgerId, ProfitAndLoss Result46 -3000.00 Credit49 -7000.00 Credit45 15000.00 Debit Please help me ProfitAndLoss Is a Decimal field and we have to separated by minus valueyou can try using your 3rd column as a computed column.if Profitandloss < 0 then 'Credit' ELSE 'Debit' ----------------------------------------------Msg 8134, Level 16, State 1, Line 1Divide by zero error encountered.
Post #1018403
 Posted Wednesday, November 10, 2010 1:16 AM
 SSC Veteran Group: General Forum Members Last Login: Monday, October 01, 2012 3:30 PM Points: 292, Visits: 1,028
 lax.rawat07 (11/10/2010)i have a result setLedgerId, ProfitAndLoss46 -3000.0049 -7000.0045 15000.00I want Result Set AsLedgerId, ProfitAndLoss Result46 -3000.00 Credit49 -7000.00 Credit45 15000.00 Debit Please help me ProfitAndLoss Is a Decimal field and we have to separated by minus valueYou can set this extra field with a case statement in your SELECT query as such:SELECT LEDGERID, PROFITANDLOSS, RESULT = CASE WHEN PROFITANDLOSS <= 0THEN CREDITELSE DEBITENDFROM MYTABLEOR, you can add a calculated field to your underlying table. Regards,goodguyExperience is a bad teacher whose exams precede its lessons
Post #1018404

 Permissions