Solved

Need a Sql Query

Posted on 2007-11-16
3
638 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 92

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
multiple application databases same MSSQL instance 5 54
dbms_crypto.decrypt   errors out 6 31
run sql script from putty 4 35
TSQL - How to declare table name 26 30
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This article describes some very basic things about SQL Server filegroups.
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 shows how to recover a database from a user managed backup

773 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