SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Display -0


Display -0

Author
Message
karthik M
karthik M
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7065 Visits: 2586
All,

I want to display -0 when i run the below query

select 0.0*-1

karthik
Kingston Dhasian
Kingston Dhasian
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6186 Visits: 5288
Getting -0 as result after performing some numeric operation is not possible
We will have to do some string concatenation to achieve this result

Can you give a bit more details as to what you are trying to do using tables, variables, etc.


Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
karthik M
karthik M
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7065 Visits: 2586
pls find the attached documents.

karthik
Attachments
Book1.xlsx (12 views, 11.00 KB)
req.txt (16 views, 2.00 KB)
Kingston Dhasian
Kingston Dhasian
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6186 Visits: 5288
You will need CASE statement and some hard-coding to achieve this result

SELECT   CASE WHEN SUM(trans_amt) BETWEEN -0.99 AND 0 THEN '-0.00' ELSE CAST( SUM(trans_amt) AS VARCHAR(30)) END
FROM acc_bal_may




Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Eugene Elutin
Eugene Elutin
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13084 Visits: 5478
Are you producing the report?
This one is one of the most stupid requirements I ever seen.
Zero, as a numeric thing, cannot be negative. Some times it used for showing temperature in weather to show that it's just low enough for water to freeze.
As soon as you add - to 0 it's stop to be numeric and starts to be a formatted string.
I would only do it in UI (eg. reporting tool).
If this is used for some sort of data extract, it's still will way better to show it in two separate columns. One is numeric value (0) and another one, CHAR(1), sign.
Than you can pass whatever you like.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search