[firebase-br] Como formatar campos dentro do select

Rubem Nascimento da Rocha djpardalrocha em hotmail.com
Qui Out 25 18:28:34 -03 2007


  select extract(month from e.aniversario) mes,
         extract(yday from e.aniversario) dia,
         case extract(month from e.aniversario)
           when 12 then 'DEZ'
           when 11 then 'NOV'
           when 10 then 'OUT'
           when 09 then 'SET'
           when 08 then 'AGO'
           when 07 then 'JUL'
           when 06 then 'JUN'
           when 05 then 'MAI'
           when 04 then 'ABR'
           when 03 then 'MAR'
           when 02 then 'FEV'
           when 01 then 'JAN'
         end nome_mes,
         case
           when extract(day from e.aniversario) < 10
           then '0' || cast(day as varchar(1))
           else cast(day as varchar(2))
         end || '/' ||
         case
           when extract(month from e.aniversario) < 10
           then '0' || cast(month as varchar(1))
           else cast(month as varchar(2))
         end niver,
         e.*
    from etiquetas_pessoas e
order by e.nome

Sds.

> From: junior em farsoft.com.br
> To: lista em firebase.com.br
> Date: Thu, 25 Oct 2007 18:21:16 -0200
> Subject: [firebase-br] Como formatar campos dentro do select
>
> Pessoal preciso fazer o seguinte:
>
> Possuo um campo que se chama niver (case end)
>
> when extract(day from e.aniversario)='1' then
> '01'||'/'||extract(month from e.aniversario)
>
> Neste ponto aonde eu tenho extract(month from e.aniversario) eu preciso
> jogar se for 7 07 ao invés
> de apenas 7.
>
>
> Existe jeito de eu fazer isto?
>
> Preciso q este campo caia num Dbgrid aonde depois vou ordená-lo clicando
> Apenas no título da coluna, e o sistema está ordenando assim oh:
>
> 01/12
> 01/7
> 31/12
>
> Ao invés de:
> 01/7
> 01/12
> 31/12
>
> Devido o 7 estar faltando com o 0 !!!
>
>
>
> Abaixo segue o código SQL:
>
> select
> extract(month from e.aniversario) as mes,
> extract(day from e.aniversario) as dia,
>
> case
> when extract(month from e.aniversario)='1' then 'JAN'
> when extract(month from e.aniversario)='2' then 'FEV'
> when extract(month from e.aniversario)='3' then 'MAR'
> when extract(month from e.aniversario)='4' then 'ABR'
> when extract(month from e.aniversario)='5' then 'MAI'
> when extract(month from e.aniversario)='6' then 'JUN'
> when extract(month from e.aniversario)='7' then 'JUL'
> when extract(month from e.aniversario)='8' then 'AGO'
> when extract(month from e.aniversario)='9' then 'SET'
> when extract(month from e.aniversario)='10' then 'OUT'
> when extract(month from e.aniversario)='11' then 'NOV'
> when extract(month from e.aniversario)='12' then 'DEZ'
> end NOME_mes,
>
> case
> when extract(day from e.aniversario)='1' then '01'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='2' then '02'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='3' then '03'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='4' then '04'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='5' then '05'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='6' then '06'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='7' then '07'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='8' then '08'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='9' then '09'||'/'||extract(month from
> e.aniversario)
> when extract(day from e.aniversario)='10' then '10'||'/'||extract(month
> from e.aniversario)
> Else extract(day from e.aniversario)||'/'||extract(month from
> e.aniversario)
> end niver,
>
> e.* from ETIQUETAS_PESSOAS e
> order by e.nome
>
>
> ______________________________________________
> FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
> Para editar sua configuração na lista, use o endereço http://mail.firebase.com.br/mailman/listinfo/lista_firebase.com.br
> Para consultar mensagens antigas: http://firebase.com.br/pesquisa

_________________________________________________________________
Receba as últimas notícias do Brasil e do mundo direto no seu Messenger com Alertas MSN! É GRÁTIS!
http://alertas.br.msn.com/



Mais detalhes sobre a lista de discussão lista