Jump to content

Sort String Column as Integer


Recommended Posts

Hey all,

Just a quick one (should be simple) - at the moment my database has a sorting function when using the screens.

However the Client Ref Number is a "String" fieldtype as the client can enter both numbers & letters.

 

However when sorting it shows the following:

Test

Testing

8044

8045

8046

22454

 

(Obviously sorting as a String rather than by numbers)

 

The to_number() in a sort throws an error as there are letters & symbols in the data.

 

Any ideas?

Regards,

Matt

Link to comment
https://forums.phpfreaks.com/topic/174435-sort-string-column-as-integer/
Share on other sites

Ok

My current code is:

  elseif ($sqlsort=="c.club_ref")
    $stmt="select * from (select c.contract_id,c.name,wc.EMAIL,wc.TELEPHONE,wc.MOBILE,c.our_ref,c.club_ref,to_char(c.sign_date,'DD-Mon-YYYY') sign_date,to_char(c.lastpay_date,'DD-Mon-YYYY') lastpay_date,c.lastpay_amt,c.stat_flag,row_number() over (ORDER BY c.club_ref desc) r from   web_members c, web_contracts wc where  c.login_id=:sucid and  c.club_id=:club_id and c.status = 'L' and c.contract_id = wc.contract_id) where r between :min_row and :max_row";

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.