Re: Help con Select

From: Anthony <asotolongo(at)uci(dot)cu>
To: Giorgio <giorgio(dot)pgsql(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Help con Select
Date: 2011-07-05 17:50:12
Message-ID: 4E134ED4.7080203@uci.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

El 05/07/2011 10:51, Giorgio escribió:
> Hola amigos espero me puedan ayudar, tengo una tabla socio mas o menos
> así:
>
> codigo..version.._modular............nombre
> 00001 01 7000000483 ALARCON ORTIZ SILVIA ESDENKA
> 00001 02 7000000483 ALARCON ORTIZ SILVIA ESDENKA
> 00002 01 1031125501 ALBINAGORTA REYNOSO HERLINDA ISABEL
> 00003 01 8000000872 ALFARO AGUERO PABLO RENE
> 00004 01 1031148858 ALTAMIRANO VARGAS AUGUSTO
> 00004 02 1031148858 ALTAMIRANO VARGAS AUGUSTO
> 00004 03 1031148858 ALTAMIRANO VARGAS AUGUSTO
> 00005 01 1031152138 ALTAMIRANO VARGAS ELIAS
> 00006 01 1031125811 ALTAMIRANO VIVANCO LUISA
> 00006 02 1031125811 ALTAMIRANO VIVANCO LUISA
> 00006 03 1031125811 ALTAMIRANO VIVANCO LUISA
> 00006 04 1031125811 ALTAMIRANO VIVANCO LUISA
>
> Donde version es el campo que diferencia el numero de version en la
> que se registra a un socio
>
> Quisiera obtener solo las ultimas versiones, teniendo en cuenta que un
> socio puede tener una version 03 o 04, la idea es que quede asi:
>
> codigo..version.._modular............nombre
> 00001 02 7000000483 ALARCON ORTIZ SILVIA ESDENKA
> 00002 01 1031125501 ALBINAGORTA REYNOSO HERLINDA ISABEL
> 00003 01 8000000872 ALFARO AGUERO PABLO RENE
> 00004 03 1031148858 ALTAMIRANO VARGAS AUGUSTO
> 00005 01 1031152138 ALTAMIRANO VARGAS ELIAS
> 00006 04 1031125811 ALTAMIRANO VIVANCO LUISA
>
>
>
prueba con esto : (espero que version sea de tipo integer o algún numerico)

SELECT
public.table1.codigo,
max(version),
public.table1.modular,
public.table1.nombre
FROM
public.table1

group by
public.table1.codigo,
public.table1.modular,
public.table1.nombre

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Daymel Bonne Solís 2011-07-05 17:50:19 Re: Help con Select
Previous Message Arcel Labrada Batista 2011-07-05 17:23:18 Re: Help con Select