Hi there,
New user here...
Got things setup and working... made my first Browse and Edit form, and loaded in some data into the database... all is displaying well...
Curious though... I have a column that displays "Price" information, and when I click the column header to sort this info, (I did format the field with nuNumber $...", as currency)
Currently sorted items look like this...(
$995.35
$99.81
$99.63
$99.51
$975.25
$975.05
$972.50
$95.35
$92.52
...etc
Is there a way to get it to sort numerically?
Thanks!
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Column Sort (Numeric?)
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Column Sort (Numeric?)
Hi and welcome !
Cast your field to float/int format when you select that field in your query and then order the result set by that column.
eg.
if it doesn't work, try this:
Cast your field to float/int format when you select that field in your query and then order the result set by that column.
eg.
Code: Select all
SELECT CAST(your_field as decimal(10,5)) AS your_field FROM table_name
Code: Select all
SELECT field1, field2, field3, field4
FROM (
SELECT field1, field2, field3, CAST(field4 as decimal(10,5)) as field4 FROM table_name
) as T
-
- Posts: 9
- Joined: Mon May 28, 2018 2:02 pm
Re: Column Sort (Numeric?)
Thank you for the response toms,
I've changed it to:
I believe I've substituted in my field and table names correctly.
However, I've tried putting it in the "Form Properties"->Browse->SQL, and doesn't seem to make a difference.
Also tried putting it in the "Form Object List"->components_price->Display (as well as 'Select'),and didn't make a difference their either.
I would suspect I'm not trying in the right places. (Apologies, I'm still learning how this all fits together).
Can you be a little more specific in where I put the SQL code?
Cheers!
Bill
I've changed it to:
Code: Select all
SELECT CAST(components_price as decimal(10,5)) AS components_price FROM components
However, I've tried putting it in the "Form Properties"->Browse->SQL, and doesn't seem to make a difference.
Also tried putting it in the "Form Object List"->components_price->Display (as well as 'Select'),and didn't make a difference their either.
I would suspect I'm not trying in the right places. (Apologies, I'm still learning how this all fits together).
Can you be a little more specific in where I put the SQL code?
Cheers!
Bill
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Column Sort (Numeric?)
Yes, in the Form Properties"->Browse->SQL
I've tried it again with a new form and the sorting works all fine, without changing the sql at all. Maybe you see a difference to your settings.
Recording:
https://vimeo.com/272243699
Database field:
numertest_number: decimal(12,4)
Input Type:
nuNumber
$ 1000.00
I've tried it again with a new form and the sorting works all fine, without changing the sql at all. Maybe you see a difference to your settings.
Recording:
https://vimeo.com/272243699
Database field:
numertest_number: decimal(12,4)
Input Type:
nuNumber
$ 1000.00
-
- Posts: 9
- Joined: Mon May 28, 2018 2:02 pm
Re: Column Sort (Numeric?)
Thanks toms!
#newbieissues#
Now I know!
Cheers
Bill

Looks like my field-type was the problem.Database field: numertest_number: decimal(12,4)
#newbieissues#
Now I know!
Cheers
Bill
