Solved

Sybase query - handling negative numbers

Posted on 2013-06-14
1
583 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
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now