sql - AVG only valid dates -


i have simple search query one:

 select count(id),         count(case when nation = 'german' 1 end),         count(case when nation = 'french' 1 end),          avg(age(birthday))   persons; 

my problem error:

  error: date out of range timestamp 

i suppose error because not every person has birthday saved.

birthday date-field

how can prevent error, , average birthdays valid dates?thanks

how this:

select count(id),         count(case when nation = 'german' 1 end),         count(case when nation = 'french' 1 end),          avg(age(coalesce(birthday, 0) ))   persons birthday not null; 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -