473,498 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RESULT IN FLOAT

HI,
I WANT THIS TO PRODUCE EXACT RESULT. (IN SQL SERVER)

SELECT (23 / 233) * 100

THE ANSWER SHOULD COME 9.871244635 OR 9.87
BUT IT RETURNS 0.

I WANT THE PERCENTAGE.

HOW TO HANDLE THIS KIND OF PROBLEM.
IS THERE ANY SET COMMAND FOR IT?
THANKS
T.S.NEGI
ti********@mind-infotech.com
Jul 20 '05 #1
1 1902
[posted and mailed, please reply in news]

T.S.Negi (ti********@mind-infotech.com) writes:
I WANT THIS TO PRODUCE EXACT RESULT. (IN SQL SERVER)

SELECT (23 / 233) * 100

THE ANSWER SHOULD COME 9.871244635 OR 9.87
BUT IT RETURNS 0.


This because in T-SQL, as in several other programming languages, /
yields integer division if both numbers are integer. The simplest
way is to say (1.0*23/233) * 100. In this way you get a floating-
point number.


--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5866
by: Michael Allen | last post by:
Hi all you Java 2D gurus out there. I wonder if you might be able to help me. I've been dipping my toe into the world of Gaussian blurring and with the help of a few articles and some bashing my...
1
1557
by: Matthias Kaeppler | last post by:
Hello, this is related to another post by me, which sort went down, so I thought I'd make a new thread. My problem is, I want to display file sizes in the format X.YZ (two digits behind the...
15
5196
by: dkultasev | last post by:
I mean, when I am trying to get result of 1/3 (or smf) it returns 0.33333333334 or something. I understand that result can not be 100% right, but it is it possibly to get more accuracy ?...
3
2182
by: Eric Davies | last post by:
We've implemented a 5D box data type and have implemented both RTree and GiST access methods under PostgresSQL 7.4 and PostgresSQL 7.4.1. The 5D box internally looks like: struct Box5D{ float...
5
5345
by: Vedran FuraĨ | last post by:
I think that this results must be the same: In : math.atan2(-0.0,-1) Out: -3.1415926535897931 In : math.atan2(-0,-1) Out: 3.1415926535897931 In : -0 == -0.0 Out: True
4
1342
by: Rico | last post by:
Hi Folks! I have a strange thing happening; I have a field that Counts the number of records and another field that shows the number of clients (Count(RecordID)=3 and NoOfClients=2) When I do a...
6
72415
by: Johs | last post by:
I have: int a = 1; int b = 2; double c = a/b; Is it somehow possible to divide these two integers and get the result as a double 0.5? Or do they both have to be declared as doubles?
27
2417
by: csledge | last post by:
Hi, I am trying to compute a 64 bit result from 2 32 bit registers, How do I get the carry into the higher word ? Also is %lld correct ? #include<stdio.h> long long int64( long x, int y);...
1
4103
by: pali | last post by:
I am running following query using Aqua Studio 4.1/AS400 DB2 select sum(amount) from table1 amount column is a decimal(11,2) I am expecting a numeric total with 2 decimal points but my result...
4
8918
by: buntyindia | last post by:
Hi, I have a calculator with seven textBox to add Float numbers upto 2 decimal: I have created following function in js: function total_expenses() { // reteriving all the values from...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.