Solved

Need a Sql Query

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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
Via a live example, show how to take different types of Oracle backups using RMAN.

733 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