Link to home
Start Free TrialLog in
Avatar of David Svedarsky
David SvedarskyFlag for United States of America

asked on

Round column numbers to nearest dollar in Sql Server 2005

I need a method to Round a column's numbers to the nearest dollar in Sql Server 2005.

Any numbers with cents (123.20) the .20 breaks the table.

Thanks for your help!
Avatar of ThomasMcA2
ThomasMcA2

In T-SQL, Round(123.20, 0) = 123.

This SQL guide is the only reference book that is on my desk. Whenever I have an SQL question, I look there first.
Avatar of David Svedarsky

ASKER

How would I structure that query?

The table is: tblPlumbingListBidDetail

The column name is: UnitPrice

I basically only work with the application that is attached to the database....
Like this:

SELECT ROUND(UnitPrice, 0)
   FROM tblPlumbingListBidDetail

Open in new window

It didn't work - probably because I have NULL values in the column?
ASKER CERTIFIED SOLUTION
Avatar of ThomasMcA2
ThomasMcA2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PortletPaul
You can use ISNULL or COALESCE to provide zero instead of null, like this:

SELECT ROUND(ISNULL(UnitPrice,0), 0), Field1, Field2, Field3
   FROM tblPlumbingListBidDetail

SELECT COALESCE(ISNULL(UnitPrice,0), 0), Field1, Field2, Field3
   FROM tblPlumbingListBidDetail

Open in new window

Thanks!