Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sql 2005 query

Posted on 2008-06-16
3
Medium Priority
?
189 Views
Last Modified: 2010-03-20
i have a query written when i select the query
i get the correct result
0044775019      638.42      VO      2008-06-06 00:00:00      CK      419116

but when i concetanate the query instead of 638.42 it is coming as 638.41 can any one tell me why is it happening like that my query is

and the result for that query is
D0010044775019        0000419116000006384120080606                        
SELECT  'D' + '001' + banknbr + SPACE(7)
      + ( CASE WHEN adjgdoctype = 'VC' THEN 'V'
                 ELSE ' '
            end ) + RIGHT(REPLICATE('0', 10)
                         + convert(VARCHAR(10), RTRIM(adjgrefnbr)), 10)
        + RIGHT(REPLICATE('0', 10)
              + CONVERT(varchar(10), CONVERT(int, ( CASE WHEN adjgdoctype = 'VC'
                                                          THEN 0
                                                         ELSE curyadjdamt * 100
                                                     end ))), 10)
        + REPLACE(CONVERT(VARCHAR, adjgdocdate, 102), '.', '') + SPACE(30)
        + NAME AS details
FROM #positivepay

Open in new window

0
Comment
Question by:romeiovasu
[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
3 Comments
 
LVL 39

Accepted Solution

by:
appari earned 2000 total points
ID: 21798620
what is the datatype of curyadjdamt? is it is float? try to change it to numeric or decimal or try the following query


SELECT  'D' + '001' + banknbr + SPACE(7)
      + ( CASE WHEN adjgdoctype = 'VC' THEN 'V'
                 ELSE ' '
            end ) + RIGHT(REPLICATE('0', 10)
                         + convert(VARCHAR(10), RTRIM(adjgrefnbr)), 10)
        + RIGHT(REPLICATE('0', 10)
              + CONVERT(varchar(10), CONVERT(int, ( CASE WHEN adjgdoctype = 'VC'
                                                          THEN 0
                                                         ELSE convert(decimal(10,2) , curyadjdamt) * 100
                                                     end ))), 10)
        + REPLACE(CONVERT(VARCHAR, adjgdocdate, 102), '.', '') + SPACE(30)
        + NAME AS details
FROM #positivepay
0
 
LVL 2

Expert Comment

by:mayno224
ID: 21798676
there's several nested command to get the value of 'curyadjdamt'.  i suggest breaking the query down to its simplest form then add to it step by step until you find where 638.41 is being returned.  for example, start with....

select curyadjdamt * 100 from positivepay

if the above returns 63842, then add the next 'step' to the query...

CASE WHEN adjgdoctype = 'VC' THEN 0 ELSE curyadjdamt * 100

select adjgdoctype, CASE WHEN adjgdoctype = 'VC' THEN 0 ELSE curyadjdamt * 100 from positivepay

keep adding 'steps' until you find where 638.41 (or '63841') is returned.  the last step that you entered will be where the problem lies.

hope this helps!
0
 

Author Comment

by:romeiovasu
ID: 21798780
thank you.
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

705 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