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
Post a Comment