Re: ORDER BY COLUMN_A, (COLUMN_B or COLUMN_C), COLUMN_D
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
From: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
To: Gavin Flower <GavinFlower@archidevsys.co.nz>
Cc: pgsql-sql@postgresql.org
Date: 2012-09-12T23:20:07Z
Lists: pgsql-sql
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.