Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
How to get a new column in the case in postgresql

I have a table with startdate and enddate.

where start date is greater than endate i need to calculate the total days as 30 otherwise (enddate - startdate)+1 ... how do i create a case statement for it.

Select case when 'startdate >  enddate' then 30
when 'startdate >  enddate' then (fine_fatturazione - startdate )+1
end
as td from table1


startdate   enddate
04-10-2015  04-12-2015
10-07-2015  09-08-2015
05-12-2015  04-01-2016
07-02-2016  04-01-2016
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Select case when table1.startdate >  table1.enddate then 30
else table1.enddate - table1.startdate + 1
end
as td 
from table1
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda