Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need a Sql Query

Posted on 2007-11-16
3
Medium Priority
?
644 Views
Last Modified: 2009-07-29
I want a Sql query to round the prices

for example  if the price is 5.01 then it should round it to 5 like wise we want to round the pennies. please send me a query for this. please let me know if my quey is correct , if not please correct it


update tablename set price=round(price,2) where pricelist='USD'

Thanks


0
Comment
Question by:gladstonesheeba
3 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 20299624
update tablename set price=round(price,0) where pricelist='USD'
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 20302926
round(price,0) -- this is to round to the nearest integer ( so we will not have decimals )

round(price,1) -- this is to round to the 1 decimal point. if you have 5.13, it gives 5.1 for this.

Thanks
0
 
LVL 5

Expert Comment

by:abith
ID: 20304106
hi gladstonesheeba

Change the DataType to numeric(10,0) for that table.

Regards
Abith K
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In this article, we’ll look at how to deploy ProxySQL.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

971 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