Solved

Sybase query - handling negative numbers

Posted on 2013-06-14
1
625 Views
Last Modified: 2013-06-17
We have a program that is needs to amounts into character strings for output, but it needs to handle negative numbers and does not.
This is the current piece of the SQL query being ran  “PAID_AMOUNT = convert(char(11),PAID_AMOUNT), “


How might we show the output with a negative number?

Looking for the SQL:
0
Comment
Question by:garyinmiami2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
alpmoon earned 500 total points
ID: 39249313
You can use str function instead of convert:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.blocks/html/blocks/blocks101.htm

str

Description:
Returns the character equivalent of the specified number.

Syntax:
str(approx_numeric [, length [, decimal] ])

Parameters

approx_numeric

    is any approximate numeric (float, real, or double precision) column name, variable, or constant expression.

length

    sets the number of characters to be returned (including the decimal point, all digits to the right and left of the decimal point, and blanks). The default is 10.

decimal

    sets the number of decimal digits to be returned. The default is 0.

Example:

select str(-12345, 6)
------
-12345
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First of all let me say that the only language that I speak is English, but in answering questions here I often come across people whose English skills are not the best and I’d like to be able to communicate better with them, and the following descr…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question