Click here to Skip to main content
15,881,882 members
Home / Discussions / Database
   

Database

 
AnswerRe: Database SQL Pin
Peter Leow11-May-14 4:13
professionalPeter Leow11-May-14 4:13 
GeneralRe: Database SQL Pin
Syafiqah Zahirah11-May-14 4:45
Syafiqah Zahirah11-May-14 4:45 
GeneralRe: Database SQL Pin
Syafiqah Zahirah15-May-14 6:50
Syafiqah Zahirah15-May-14 6:50 
GeneralRe: Database SQL Pin
Peter Leow15-May-14 14:47
professionalPeter Leow15-May-14 14:47 
QuestionArithmetic rounding Pin
Richard.Berry1009-May-14 11:04
Richard.Berry1009-May-14 11:04 
AnswerRe: Arithmetic rounding Pin
Richard Andrew x649-May-14 12:26
professionalRichard Andrew x649-May-14 12:26 
GeneralRe: Arithmetic rounding Pin
Richard.Berry1009-May-14 20:58
Richard.Berry1009-May-14 20:58 
AnswerRe: Arithmetic rounding Pin
Andrius Leonavicius9-May-14 15:02
professionalAndrius Leonavicius9-May-14 15:02 
Hi,

The problem is not a ROUND function, but the precision of the FLOAT data type (Using decimal, float, and real Data[^]). You have at least a couple of options:
1. Use DECIMAL or NUMERIC instead of the FLOAT.
2. CAST to DECIMAL for the calculation.

Here's the demonstration for you (using your first example):
1. Select using ROUND.
SQL
SELECT ROUND((7.5169 * 745), 3) AS Result;

or
SQL
SELECT ROUND(5600.0905, 3) AS Result;

Result: 5600.0910

2. Using FLOAT variables.
SQL
DECLARE @a FLOAT, @b FLOAT, @c FLOAT;
SET @a = 7.5169;
SET @b = 745;
SET @c = @a * @b;
SELECT ROUND(@c, 3) AS Result;

Result: 5600.09

3. Using DECIMAL variables.
SQL
DECLARE @a DECIMAL(18, 4), @b DECIMAL(18, 4), @c DECIMAL(18, 4);
SET @a = 7.5169;
SET @b = 745;
SET @c = @a * @b;
SELECT ROUND(@c, 3) AS Result;

Result: 5600.0910

P.S. I am posting such data with the XML pre tag. Also, I am inserting (copying) TAB characters (if needed).
Best regards,
Andrius Leonavicius

GeneralRe: Arithmetic rounding Pin
Richard.Berry1009-May-14 20:45
Richard.Berry1009-May-14 20:45 
GeneralRe: Arithmetic rounding Pin
Andrius Leonavicius10-May-14 4:28
professionalAndrius Leonavicius10-May-14 4:28 
QuestionFetch records efficiently Pin
avi_dadi20029-May-14 9:15
avi_dadi20029-May-14 9:15 
AnswerRe: Fetch records efficiently Pin
Richard Andrew x649-May-14 10:30
professionalRichard Andrew x649-May-14 10:30 
AnswerRe: Fetch records efficiently Pin
Richard MacCutchan9-May-14 21:49
mveRichard MacCutchan9-May-14 21:49 
QuestionNeed to fetch from two data sources Pin
avi_dadi20029-May-14 9:11
avi_dadi20029-May-14 9:11 
AnswerRe: Need to fetch from two data sources Pin
Richard.Berry1009-May-14 21:40
Richard.Berry1009-May-14 21:40 
QuestionSSAS Cube Pin
Mycroft Holmes6-May-14 14:42
professionalMycroft Holmes6-May-14 14:42 
QuestionNeed help in forming a query Pin
Member 99559846-May-14 0:07
professionalMember 99559846-May-14 0:07 
AnswerRe: Need help in forming a query Pin
Richard MacCutchan6-May-14 0:21
mveRichard MacCutchan6-May-14 0:21 
Questionlogin and logout differenece at back end Pin
Syed Rehman5-May-14 18:59
Syed Rehman5-May-14 18:59 
AnswerRe: login and logout differenece at back end Pin
Mycroft Holmes5-May-14 19:20
professionalMycroft Holmes5-May-14 19:20 
QuestionMigration error from SQL 2014 to SQL 2012 Pin
Kala Vairakkannu5-May-14 7:48
Kala Vairakkannu5-May-14 7:48 
AnswerRe: Migration error from SQL 2014 to SQL 2012 Pin
ZurdoDev5-May-14 9:36
professionalZurdoDev5-May-14 9:36 
QuestionMigration error from SQL 2014 to SQL 2012 Pin
Kala Vairakkannu5-May-14 7:27
Kala Vairakkannu5-May-14 7:27 
AnswerRe: Migration error from SQL 2014 to SQL 2012 Pin
Kornfeld Eliyahu Peter5-May-14 7:34
professionalKornfeld Eliyahu Peter5-May-14 7:34 
GeneralRe: Migration error from SQL 2014 to SQL 2012 Pin
ZurdoDev5-May-14 7:48
professionalZurdoDev5-May-14 7:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.