How to sort values with too many characters?

Asked

Viewed 97 times

1

good afternoon I’m doing a query that fetches values that return like this:

TEST-1
TEST-2
TEST-3
TEST-4
TEST-5
TEST-10
TEST-11

but when it reaches 10 it orders by the first character for example:

TEST-1
TEST-10
TEST-11
TEST-2
TEST-3
...

can anyone help me the query I’m doing is this:

SELECT 
    num_pedido,
    nota_fiscal,
    lote_serial,
    produto,
    qtd_disp,
    lote,
    unid_medida,
    pedido,
    status
FROM
    coleta_ordem.clientes_ag 
    order by length(right(pedido,1)), right(pedido,1) asc, length(right(pedido,2)), right(pedido,2);
  • 1

    manage to do was picking up the wrong column sorry to bother

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.