Solved

Sybase query - handling negative numbers

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

862 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

23 Experts available now in Live!

Get 1:1 Help Now