473,473 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ORDER BY with floating point formula does not work?

38 New Member
Hello,
I have a problem getting 'Order By' to work properly on calculated results producing floating point value in MySql.

Ordering by single columns seems to work ok (like 'ORDER BY t2.Col4' in the query below).

This is a stripped version of my query:
Expand|Select|Wrap|Line Numbers
  1. SELECT t2.Col4, ROUND(SUM(t1.Col1 * t2.Col3) / SUM(t1.Col2), 2)
  2. FROM  Table1 AS t1, Table2 AS t2
  3. Where t1.Col4 = t2.Col1 ....
  4. GROUP BY t1.Col3
  5. ORDER BY ROUND(SUM(t1.Col1 * t2.Col3) / SUM(t1.Col2), 2);
  6.  
Any idea what it might be?
Could it be that I have the formula in the order by expression? If so, how can I specify which rendered column number I want to order by?
Note: do not pay attention to the where clause in this stripped version, in my unstripped version the where clause is complete and the rendered values are as expected.

best regards
Kurt
Jul 13 '07 #1
2 3726
mwasif
802 Recognized Expert Contributor
You can use alias for ORDER BY

Expand|Select|Wrap|Line Numbers
  1. SELECT t2.Col4, ROUND(SUM(t1.Col1 * t2.Col3) / SUM(t1.Col2), 2) AS total
  2. FROM Table1 AS t1, Table2 AS t2
  3. Where t1.Col4 = t2.Col1 ....
  4. GROUP BY t1.Col3
  5. ORDER BY total;
What you are expecting and what you are receving from the query? it will be better if you can describe by sample data.
Jul 13 '07 #2
Kurt Jakobsen
38 New Member
Thank you mwasif!
that was the fix
best regards
Kurt :-)
Jul 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: j_mckitrick | last post by:
I checked the docs, but found nothing about floating point issues. I am working on an app that deals with currency values, and only does addition and subtraction (no division). But I am starting...
24
by: j0mbolar | last post by:
C supports single precision floating point and double precision floating point but does it support fixed floating point? i've read that fixed floating point is more accurate than single precision...
10
by: Shawn | last post by:
Hello all, I apologize as I am sure this has probably been dealth with before... but I am doing an exercise from "Practical C Programming" and I have been unable to get it to work perfectly due to...
7
by: Daniel Vallstrom | last post by:
I am having trouble with floating point addition because of the limited accuracy of floating types. Consider e.g. x0 += f(n) where x0 and f are of some floating type. Sometimes x0 is much larger...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
9
by: David Veeneman | last post by:
I'm working on a project that uses floating-point values (doubles), and I'm being driven crazy by something pretty basic. I understand that it's in the nature of floating-point calculations to...
27
by: G Patel | last post by:
Hello, I'm having trouble with floating point problems. I'm trying to write a function that calculates the distance between two cartesian points (integer coordinates). I have the function...
33
by: dis_is_eagle | last post by:
hi....i have encountered strange problem regarding floating point comparison...the problem is... main() { float a=0.7; if(0.7 a) printf("hi"); else printf("hello");
1
by: ilSignorCarlo | last post by:
Hi, is there any way to use the slider in the range between 0 and 1 getting up to 100 or 1000 values?
0
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
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,...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.