CREATE VIEW vUsiaAnakAll
as
SELECT ch.child_id, ch.child_name,ch.child_birthday,  ch.customer_id,PERIOD_DIFF(DATE_FORMAT(CURDATE(),'%Y%m'),DATE_FORMAT(ch.child_birthday,'%Y%m')) as umur
FROM children ch inner join customer cu using (customer_id)
WHERE cu.followup_status='1' and ((ch.child_birthday >= (date_sub(curdate(), interval 36 month)))
and (ch.child_birthday <= (date_sub(curdate(), interval 0 month))))
order by ch.child_birthday

0 Comments:

Post a Comment