postgresql - SQL IF [complex condition] THEN OUTPUT NEW TABLE -


i'm not sure how approach problem.

i need output table containing 1 row "yes" if complex condition met. how got doing this?

the condition this: "if age difference between oldest , youngest professors between 2004 , 2008 @ 10 years"...

i'm using postgresql.

thanks.

based on description, should work.

select   case when     (date_part('year', max(birthdate)) - date_part('year', min(birthdate))) * 12 +     (date_part('month', max(birthdate)) - date_part('month', min(birthdate)))     <= 120 'yes'   else 'no'   end professors dateemployed between '2004-01-01' , '2008-12-31'; 

sql fiddle example


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -