Get last 7 days records from table in zend

2019-08-20 10:04发布

问题:

Hi guys i am trying to get last 7 days closed tickets from table Here is the query i have wrote

'closed' => new Zend_Db_Expr('SUM(IF(rt.assignee_id IS NOT NULL,IF(rt.status_id = 24,1,0),0))')

can any one help me how can i add my condition inside IF?

Thanks in advance.

回答1:

'closed' => new Zend_Db_Expr('SUM(IF(rt.assignee_id IS NOT NULL, IF(rt.status_id = 24, IF(created >= CURDATE() - INTERVAL 7 DAY, 1,0),0),0))')

not 100% sure about the CURDATE() - INTERVAL 7 DAY, but i think you will understand it.