SELECT iweb_mailing_messages.*, (SELECT  COUNT(id) FROM iweb_mailing_emails WHERE id_message = iweb_mailing_messages.id)  AS messages_total, (SELECT COUNT(id) FROM iweb_mailing_emails WHERE email_sent = 1 AND id_message=iweb_mailing_messages.id) as messages_sent FROM iweb_mailing_messages GROUP BY id ORDER BY sending_date DESC