View previous topic :: View next topic
|
Author |
Message |
mahesh pillai
New User
Joined: 04 Oct 2011 Posts: 6 Location: india
|
|
|
|
Hi Friends,
I have to extract a report from one of the database table. I have an issue with one of the column which is having a decimal value.
The user wants that if the value of this field is '0' then it should be reflected as 'SPACES' in the final report.
The datatype of this column is DECIMAL(9,2). I tried converting this column to character first using CHAR function and then trying to REPLACE the values but in vain. I am creating the report using the STRIP function and tried using the belwo query:
STRIP(CHAR(REPLACE(COLUMN NAME,'0.00',' '))) |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Why not do it in your program instead of your SQL? |
|
Back to top |
|
|
mahesh pillai
New User
Joined: 04 Oct 2011 Posts: 6 Location: india
|
|
|
|
The user doesn't want us to write a new program but to do it via queries.
We don't have funding for the same. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
This almost work:
Code: |
CASE WHEN YourColumn = 0
THEN ' '
ELSE CAST(YourColumn AS CHAR(12))
END |
I say almost because numbers become left justified and "0.5" shows as ".5"
but it's a start... |
|
Back to top |
|
|
mahesh pillai
New User
Joined: 04 Oct 2011 Posts: 6 Location: india
|
|
|
|
Hi Marso,
Thanks a lot for your help here. This has worked perfectly fine and report output is as expected.
Thanks again. |
|
Back to top |
|
|
|