Solved

Need a Sql Query

Posted on 2007-11-16
3
642 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
[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 93

Accepted Solution

by:
Patrick Matthews earned 125 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

626 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