Solved

Sybase query - handling negative numbers

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Importing data to Sybase, getting "EOF encountered" error 3 752
Sybase 15.7 database backup 8 632
Linked Server to connect using Advantage OLEDB from MS SQL 18 2,244
SQL Query Syntax 17 162
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 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