Em 12-09-2012 19:34, Gavin Flower escreveu:
On 13/09/12 09:44, Rodrigo Rosenfeld Rosas wrote:
This is my first message in this list :)

I need to be able to sort a query by column A, then B or C (which one
is smaller, both are of the same type and table but on different left
joins) and then by D.

How can I do that?

Thanks in advance,
Rodrigo.


...
SELECT
    *
FROM
    tabc t
ORDER BY
    t.a,
    LEAST(t.b, t.c),
    t.d
...

Thank you Gavin, I was looking for this LEAST function for a long time. I have tried MIN but it didn't work with strings.

I guess this will allow me to do what I want. Thank you so much!

Best,
Rodrigo.

Reply via email to