473,493 Members | 4,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Formatted number column cannot be sorted by number

dlite922
1,584 Recognized Expert Top Contributor
This is again from the dynamic reporting module i'm building.

Columns come in and are built based on XML doc and the HTML (smarty template) does not know weather this is a number to format it nicely such as 2345.993 to 2,346.99.

So I do my formatting in the XML which gives the dynamic query developer something similar this:

FORMAT(price * qty,2) AS sales

All was fine and dandy until i wanted to sort it by number. Turns out Format makes it as string and it does a string sort, in other words it would sort it like this:

1223
21
90

So a genius (/sarcasm) told me to "add a zero" to it and it would work.

nope, it turned 2,345.00 into 2.00. (had to explain to the client why his biggest sale was showing up as 2.00)

Now i've converted it to ROUND()

but is there any other way to have the comma (thousands delimiter) as well has have mySQL treat it as a number?

Thanks for your feedback,


Dan
Jun 25 '08 #1
3 1489
r035198x
13,262 MVP
I don't think formatting should be done by the database at all.
The front end should format based on the user's preferences. What are you using for the front-end?
Jun 25 '08 #2
Atli
5,058 Recognized Expert Expert
I would have to agree with r035198x.

Any manipulation of the data should be done at a "presentation level"... i.e. using whatever API you use to present the data to you users.
Jun 25 '08 #3
dlite922
1,584 Recognized Expert Top Contributor
I would have to agree with r035198x.

Any manipulation of the data should be done at a "presentation level"... i.e. using whatever API you use to present the data to you users.
guys, guys, read the OP. I said i'm using smarty, but since its all dynamic, how could smarty know weather its a text, a phone number or a dollar amount.

If there is no way, then I'll live with it and switch to ROUND(). That's all I was asking. Maybe I wasn't clear. Sometimes I babble on and on..like this. :)

thanks for the replies though,


Dan
Jun 27 '08 #4

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

Similar topics

8
7798
by: Michelle | last post by:
hi, i have created an array from recordset containing user names eg. (davidp, davidp, evenf, patricka, rebeccah) which i have sorted in alphabetical order, but i need to identify duplicates...
5
11485
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
3
4201
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone...
10
4924
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
1
1387
by: Stefan Mueller | last post by:
In my example the focus should only jump to textbox2 if you press the tab key and if '11' is in textbox1. That works fine. However if you enter e.g. '12' in textbox1 and click on 'Link', Mozilla...
6
2702
by: bfowlkes | last post by:
Hello, I am trying to parse two pre-formatted text files and write them to a different files formatted in a different way. The story about this is I was hired along with about 20 other people...
3
2098
by: thehuby | last post by:
I have a website with a two column layout. Everything is fine, got most of my cross browser issues sorted but have discovered a major bug that I cannot fix (in IE shock horror). The news...
5
1938
by: vpravin | last post by:
Hi guys...i am a super noob with html and aspx.. i didnt start this project but i am modifying it... q: how do i change the width of a column: Thats the table which is within a text box ...
2
1311
by: Crazineko | last post by:
Hello all, I am fairly new to Access and am running into a problem. I am looking at a table that has all phone numbers that have called our business for the month of November. However, many of...
0
7118
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
7157
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
7364
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
5452
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,...
1
4886
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
4579
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
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
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.