[firebase-br] Select da maior data de vencimento.

Marcos Carlos mlimacarlos em gmail.com
Ter Dez 1 19:40:06 -03 2015


select tt.* from tabela tt
inner join (select cod_aluno, max(dt_venc) as a from tabela group by
cod_aluno) g
on tt.cod_aluno = g.cod_aluno
and tt.dt_venc = g.a

Marcos de Lima Carlos
mail to: mlimacarlos em gmail.com
http://blog.sirandsir.com/  <http://blog.sirandsir.com/> - Blog da Sir & Sir
http://inventory.sirandsir.com/ - Sir&Sir inventory!

<http://www.sirandsir.com>


Em 1 de dezembro de 2015 18:47, Cezar Moniz <cezar em rtcm.com.br> escreveu:

> Prezados,
>
> Estou realmente com um problema, do qual acredito já ter solução, mas como
> final de Ano é meta a pressa é inimiga da perfeição.
>
> Preciso da ajuda para selecionar na tabela (vencimentos),  abaixo,  somente
> os registros com a MAIOR data de vencimento (DT_VENC) sem repetição das
> outras datas MENORES ou inferiores .
>
> Assim
>
> DT_VENC DT_PAGTO      PG  VLR_M VLR_REC CODIGO_ALUNO
> 13/11/2015 13/10/2015 S 100 100 3 NAO APARECER
> 10/12/2015 10/11/2015 S 100 100 3 OK
> 10/12/2015 10/11/2015 S 100 100 4 OK
> 13/11/2015 13/10/2015 S 100 100 4 NAO APARECER
> 10/12/2015 10/11/2015 S 100 100 5 OK
> 06/11/2015 07/10/2015 S 120 120 5 NAO APARECER
> 02/11/2015 02/10/2015 S 216 216 6 OK
> 03/10/2015 02/09/2015 N 100 100 7 OK
> 10/12/2015 10/11/2015 S 100 100 8 OK
> 06/11/2015 06/10/2015 S 100 100 8 NAO APARECER
> 03/12/2015 01/11/2015 S 120 120 9
> 06/11/2015 06/10/2015 S 100 100 10
> 05/12/2015 05/11/2015 S 100 100 10
> 03/10/2015 02/09/2015 N 120 120 11
> 03/12/2015 01/11/2015 S 100 100 12
> 09/11/2015 09/10/2015 S 120 120 13
> 04/12/2015 04/11/2015 S 120 120 14
> 16/11/2015 16/10/2015 S 120 120 14
> 04/12/2015 04/11/2015 S 120 120 15
>
> Obrigado a todos.
>
> --
> Atenciosamente,
> ______________________________________________
> FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
> Para saber como gerenciar/excluir seu cadastro na lista, use:
> http://www.firebase.com.br/fb/artigo.php?id=1107
> Para consultar mensagens antigas:
> http://www.firebase.com.br/pesquisa_lista.html
>



Mais detalhes sobre a lista de discussão lista