|
|
concatenating and two decimal places
Hello:
Below is my query, and I need help with two things.
First, I am trying to get each field in this query to be concatenated
together. But, there is a space between the field "CMTrxNum" and "CASE WHEN
TRXAMNT....". How do I get rid of this spacing?
Secondly, I need for the two fields that contain the phrases
"CAST(-1*TRXAMNT as varchar)" and "CAST(TRXAMNT as varchar)" to be two
decimal places. How do I do this?
select '2000038028654' + '0000' + CMTrxNum + CASE WHEN TRXAMNT <0 THEN
CAST(-1 * TRXAMNT as varchar)
ELSE CAST(TRXAMNT as varchar) END
+ convert(varchar, TRXDATE, 112)
+ CASE WHEN VOIDED = '1' then 'V' ELSE '' END
from CM20200
where CHEKBKID = 'UPTOWN TRUST' and SOURCDOC = 'PMPAY' or SOURCDOC = 'PMCHK'
SQL Programmer (it's just a name)
|
|
0
|
|
|
|
Reply
|
Utf
|
5/24/2010 2:37:01 AM |
|
It is good practice to always specify the VARCHAR length. Try this:
SELECT '2000038028654' + '0000' + CMTrxNum +
CASE WHEN TRXAMNT < 0 THEN LTRIM(STR(-1 * TRXAMNT, 20, 2))
ELSE LTRIM(STR(TRXAMNT, 20, 2))
END + CONVERT(VARCHAR(8), TRXDATE, 112) +
CASE WHEN VOIDED = '1' THEN 'V' ELSE '' END
FROM CM20200
WHERE CHEKBKID = 'UPTOWN TRUST'
AND SOURCDOC IN ('PMPAY', 'PMCHK');
--
Plamen Ratchev
http://www.SQLStudio.com
|
|
0
|
|
|
|
Reply
|
Plamen
|
5/24/2010 3:06:29 AM
|
|
|
1 Replies
497 Views
(page loaded in 0.035 seconds)
Similiar Articles: concatenating and two decimal places - microsoft.public.sqlserver ...Hello: Below is my query, and I need help with two things. First, I am trying to get each field in this query to be concatenated together. Bu... Decimal places in mail merge - microsoft.public.word.docmanagement ...In the Excel spreadsheet I have set the values format as general, with 2 decimal places. In the merge it still carries it out 10 or so places. Need to decrease decimal places for an active currency ID ...concatenating and two decimal places - microsoft.public.sqlserver ... Need to decrease decimal places for an active currency ID ... We currently have the JPY (Japanese YEN ... Zero decimal getting dropped. - microsoft.public.access.forms ...concatenating and two decimal places - microsoft.public.sqlserver ... Zero decimal getting dropped. - microsoft.public.access.forms ... I produce a report with a number to ... how to truncate to 2 decimal places - microsoft.public.sqlserver ...concatenating and two decimal places - microsoft.public.sqlserver ... how to truncate to 2 decimal places - microsoft.public.sqlserver ... Via a calculation, how do you ... Cast Varchar to Decimal? - microsoft.public.sqlserver.programming ...concatenating and two decimal places - microsoft.public.sqlserver ... Secondly, I need for the two fields that contain the phrases "CAST(-1*TRXAMNT as varchar)" and "CAST ... Decimal places in the result of formula in PWA2007 - microsoft ...concatenating and two decimal places - microsoft.public.sqlserver ... Decimal places in the result of formula in PWA2007 - microsoft ... Hello, How can we manage the ... keep source formatting when concatenating - microsoft.public.excel ...When concatenating to D1 (=CONCATENATE(A1&" "&B1&" "&C1), the source formatting ... Rounding off numbers to 2 decimal places. - microsoft.public ..... Measure-Object ... Concatenate 2 columns date & time - microsoft.public.excel ...... would be seen by Excel as (10+55/60)/24 which is 0.454861111 to nine decimal places. ... Concatenate 2 columns date & time - microsoft.public.excel ..... have a ws that I ... Adding currency fields together - microsoft.public.access.queries ...concatenating and two decimal places - microsoft.public.sqlserver ..... each field in this query to be concatenated together. ... Secondly, I need for the two fields ... concatenating and two decimal places - microsoft.public.sqlserver ...Hello: Below is my query, and I need help with two things. First, I am trying to get each field in this query to be concatenated together. Bu... concatenating and two decimal places SQL ServerHello: Below is my query, and I need help with two things. First, I am trying to get each field in this query to be concatenated together. But, there i Excel - Decimal Places In A Concatenation - Hi How would... - Free ...Decimal Places In A Concatenation - Hi How would I remove the decimal places when concatenating... - Free Excel Help Excel - Concatenate With 2 Decimal Places - Hi folks I can get ...Concatenate With 2 Decimal Places - Hi folks I can get concatenate to work showing spaces... - Free Excel Help Concatenate and Decimal places - Excel Templates | Excel Add-ins ...Hi All, I am facing a problem with Excel's Concatenate function. I am trying to make ... very similiar to a thread I advised on this morning. http://www.ozgrid.com ... 7/23/2012 6:48:24 PM
|
|
|
|
|
|
|
|
|