Solved

sql 2005 query

Posted on 2008-06-16
3
188 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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

631 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