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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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"?
pepps11976Author Commented:
it has number values in displayed as

-150.00
-55.92
-25.99

etc
Lee SavidgeCommented:
This?

select nt_value, abs(nt_value) as FixedValue from mytable

Open in new window

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
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

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.
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
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

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.