On 06/21/2013 12:45 PM, Paul J Stevens wrote:
Pavlo,
I think I fixed this. Can you please checkout revision:
http://git.dbmail.eu/paul/dbmail/patch/?id=8e679a87afaf4a16facfb7b2c1c575c8d9fa6545
Yep, this works ok, thanks, sorry for feedback delay.
Also if you are opened for suggestions than I propose next query:
SELECT
SUM( CASE WHEN seen_flag = 0 THEN 1 ELSE 0 END) AS unseen,
SUM( CASE WHEN seen_flag = 1 THEN 1 ELSE 0 END) AS seen,
SUM( CASE WHEN recent_flag = 1 THEN 1 ELSE 0 END) AS recent
FROM %smessages WHERE mailbox_idnr=? AND status < %d
This variant is slightly more preferable because it lacks GROUP BY statement
which adds
implicit ORDER BY.
http://dev.mysql.com/doc/refman/5.1/en/select.html
If you use GROUP BY, output rows are sorted according to the GROUP BY columns
as if you
had an ORDER BY for the same columns. To avoid the overhead of sorting that
GROUP BY
produces, add ORDER BY NULL
The resultset will have one record only (the same input data):
+--------+------+--------+
| unseen | seen | recent |
+--------+------+--------+
| 6 | 2 | 6 |
+--------+------+--------+
--
Best regards,
Pavlo Lavrenenko,
PortaOne, Inc., Junior Software Developer
Tel: +1-866-SIP VOIP (+1 866 747 8647) ext. 7624
PortaOne - VoIP Solutions Company
Visit our Website: http://www.portaone.com
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev