user2457175
user2457175

Reputation: 31

Order MySQL Table by Ascending Order (Numbers)

i want to arrange est_dilt_pple table in ascending order.

   pub_name                               est_dily_pple
    Jex Max Publication                         11530
    BPP Publication Mumbai                  123500    
    New Harrold Publication                     12563
    Ultra Press Inc.                            9500
    Mountain Publication                        9300
    Summer Night Publication                    53698
    Pieterson Grp. of Publishers                50000

i tried this

SELECT * FROM publisher ORDER BY est_dily_pple ASC;

Result

pub_name                               est_dily_pple
Jex Max Publication                         11530
BPP Publication Mumbai                  123500
New Harrold Publication                     12563
Pieterson Grp. of Publishers                50000    
Summer Night Publication                    53698
Mountain Publication                        9300
Ultra Press Inc.                            9500

PROBLEM

But it is not ascending. "123500" is more than all, it should showed at bottom. any help me in this please!

Upvotes: 0

Views: 1912

Answers (2)

AllTooSir
AllTooSir

Reputation: 49432

The best solution is to make the datatype of column est_dily_pple numeric. Or else you can try this :

SELECT * FROM publisher ORDER BY CAST(est_dily_pple as SIGNED INTEGER) ASC

Upvotes: 0

duffymo
duffymo

Reputation: 309008

Looks like the column is a text or varchar type, with string sorting semantics.

Make it an integer or number type and you'll fare better.

Upvotes: 4

Related Questions