Skip site navigation (1) Skip section navigation (2)

Re: Union

From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "Victor Lopez" <d01m01a2000(at)gmail(dot)com>
Cc: "Felipe Fernandez" <ffdezrguez(at)tiscali(dot)es>, Postgresql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Union
Date: 2007-04-28 04:30:33
Message-ID: c2d9e70e0704272130q4d75d7bdp5bcb0b503a795f70@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
On 4/27/07, Victor Lopez <d01m01a2000(at)gmail(dot)com> wrote:
> > select referencia, foto1, localidad
> > from (
> > SELECT REFERENCIA,FOTO1,LOCALIDAD, fecha, hora
> > FROM tabla1
> > WHERE FOTO1 != ''
> >               AND ESTADO = 3
> >               AND CATEGORIA IN (SELECT CODIGO FROM CATEGORIAS WHERE GRUPO=6)
> >              AND DESTACADO = TRUE
> > UNION ALL
> > SELECT REFERENCIA,FOTO1,LOCALIDAD, fecha, hora
> > FROM tabla1
> > WHERE FOTO1 != ''
> >               AND ESTADO = 3
> >               AND CATEGORIA IN (SELECT CODIGO FROM CATEGORIAS WHERE GRUPO=6)
> >               AND  DESTACADO = FALSE
> > ) foo
> > ORDER BY FECHA DESC, HORA DESC LIMIT 1;
> >
>
> Por interpretar ... yo interpreto que quiere que los destacados salgan
>  antes de los no destacados.
>
> Pregunta :
>
> ORDER BY DESTACADO ASC, ....
> o
> ORDER BY DESTACADO DESC, ...
>

no. porque lo esta ordenando explicitamente por fecha y hora, no por destacado
> ORDER BY FECHA DESC, HORA DESC LIMIT 1;

-- 
Atentamente,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
                                       Richard Cook

In response to

  • Re: Union at 2007-04-28 04:00:13 from Victor Lopez

Responses

  • Re: Union at 2007-04-28 04:33:32 from felipe fernandez

pgsql-es-ayuda by date

Next:From: felipe fernandezDate: 2007-04-28 04:33:32
Subject: Re: Union
Previous:From: Jaime CasanovaDate: 2007-04-28 04:14:34
Subject: Re: Optimizar Vista

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group