logo       

Re: Select: msg#00577

db.postgresql.brasil

Subject: Re: Select

On Tue, Mar 25, 2003 at 02:15:27PM -0300, Hugo Sacramento wrote:
> Galera,
>
> Tenho uma tabela que possui uma data e uma sequencia diária por data.
> Ex:
>
>
> 22/03 1
> 22/03 2
>
> 24/03 1
> 24/03 2
> 24/03 3
>
> 25/03 1
> 25/03 2
>
> Como faço para saber qual é o anterior imediato a um desses registros.
> Por Exemplo, se fosse incluir um registro com data 23/03, como eu
> saberia que o anterior a ele é o 22/03-2.

SELECT
data, reg
FROM
minha_tabela
WHERE
data < <data_desejada>
ORDER BY
data, reg desc
LIMIT
1;

Acho que isso vai funcionar. Como você não mandou a definição da tabela,
não pude testar.

-Roberto

--
+----| Roberto Mello - http://www.brasileiro.net/ |------+
+ Computer Science Graduate Student, Utah State University +
+ USU Free Software & GNU/Linux Club - http://fslc.usu.edu/ +
I love Edlin for Windows: PC-Magazine Editor's Choice!

----------------------------------------------------------
Grupo PostgreSQL Brasil. Fundado em 1999.
Mensagens para: postgresql-br-EYaqaC9dFX8MqA7zqLjoiV/I71DsQ//L@xxxxxxxxxxxxxxxx
Desassociação:
postgresql-br-unsubscribe-EYaqaC9dFX8MqA7zqLjoiV/I71DsQ//L@xxxxxxxxxxxxxxxx
Site Web: http://br.groups.yahoo.com/group/postgresql-br


Seu uso do Yahoo! Grupos é sujeito às regras descritas em:
http://br.yahoo.com/info/utos.html





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise