Здравствуйте как написать данный запрос:
SELECT *
FROM (
SELECT `user_id` as ids,`created`,`order_id`
FROM `order`
WHERE
`created` < ( NOW( ) - INTERVAL 30 DAY )
ORDER BY `created` DESC
) AS orders
LEFT JOIN `users` ON `orders`.`ids` = `users`.`user_id`
GROUP BY `user_id`
HAVING count( `user_id` ) >=1
в zend orm(query_builder)