SQL Query

Hi All I have the following Query

SELECT     TOP (100) PERCENT nt_acnt, nt_cntr, nt_type, nt_subt, nt_jrnl, nt_ref, nt_inp, nt_cmnt, nt_trnref, nt_entr, nt_value, nt_year, nt_period, nt_rvrse, nt_prevyr, nt_consol, 
                      nt_fcurr, nt_fvalue, nt_fcrate, nt_fcmult, nt_fcdec, nt_srcco, nt_cdesc, id, nt_project, nt_job, nt_posttyp, nt_pstgrp, nt_pstid, nt_srcnlid, nt_recurr, nt_perpost, nt_rectify, 
                      nt_recjrnl, nt_vatanal, nt_distrib
FROM         dbo.ntran
WHERE     (nt_acnt = '4919')
ORDER BY nt_entr

Open in new window


The Column nt_value displays as - Figure, is there a sum I can do on this column to make it a non - Figure
pepps11976Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee SavidgeCommented:
Waht do you mean when you say it displays as "- Figure"?
0
pepps11976Author Commented:
it has number values in displayed as

-150.00
-55.92
-25.99

etc
0
Lee SavidgeCommented:
This?

select nt_value, abs(nt_value) as FixedValue from mytable

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Olaf DoschkeSoftware DeveloperCommented:
If these values are "displayed as" negative figures, then they are negative figures. So you may want to fix a display issue, but rather have a data issue. Or wrong assumptions about the data.

While ABS() is the technical answer to turn any figure into an absolute, positive figure it would obviously read any debit as credit, or any withdrawal as a deposit.

Assuming ntran means something like transaction you might want to split your nt_value data to two columns withdraw, deposit depending on being negative or positive, where one of them will be the absolute amount and the other 0. Then ABS() will only help partially, it'll not categorize the nature of the transaction. What you'd need is some CASE about nt_value being <0 or >0. The exact syntax will depend on what database you use, you've tagged your question as MSSQL and MySQL, what is it, really?

Bye, Olaf.
0
pepps11976Author Commented:
Ok I added the following

SELECT     TOP (100) PERCENT nt_acnt, nt_cntr, nt_type, nt_subt, nt_jrnl, nt_ref, nt_inp, nt_cmnt, nt_trnref, nt_entr, nt_value, ABS(ntvalue) AS FixedValue, nt_year, nt_period, 
                      nt_rvrse, nt_prevyr, nt_consol, nt_fcurr, nt_fvalue, nt_fcrate, nt_fcmult, nt_fcdec, nt_srcco, nt_cdesc, id, nt_project, nt_job, nt_posttyp, nt_pstgrp, nt_pstid, nt_srcnlid, 
                      nt_recurr, nt_perpost, nt_rectify, nt_recjrnl, nt_vatanal, nt_distrib
FROM         dbo.ntran
WHERE     (nt_acnt = '4919')
ORDER BY nt_entr

Open in new window


but I am getting an error running the query
0
pepps11976Author Commented:
Nope my mistake I had a typo
SELECT     TOP (100) PERCENT nt_acnt, nt_cntr, nt_type, nt_subt, nt_jrnl, nt_ref, nt_inp, nt_cmnt, nt_trnref, nt_entr, nt_value, ABS(ntvalue) AS FixedValue, nt_year, nt_period, 
                      nt_rvrse, nt_prevyr, nt_consol, nt_fcurr, nt_fvalue, nt_fcrate, nt_fcmult, nt_fcdec, nt_srcco, nt_cdesc, id, nt_project, nt_job, nt_posttyp, nt_pstgrp, nt_pstid, nt_srcnlid, 
                      nt_recurr, nt_perpost, nt_rectify, nt_recjrnl, nt_vatanal, nt_distrib
FROM         dbo.ntran
WHERE     (nt_acnt = '4919')
ORDER BY nt_entr

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.