How do I modify this MySQL query to only count leadIDs from table leads where column ‘Date’ contains the newest (youngest) date?
SELECT COUNT(leadID) as accepted FROM leads WHERE change like '%OK%'
The problem is that leadID can have multiple instances in table leads. The original query result is “4” because of one duplicate. The correct result is “3”.
The date is stored in this format: 2011-10-26 18:23:52. The result should take hours and minutes into consideration when determining the youngest date.
TABLE leads:
leadID | date | change 1 | 2011-10-26 18:23:52 | BAD 1 | 2011-10-26 17:00:00 | OK 2 | 2011-10-26 19:23:52 | OK 3 | 2011-10-26 20:23:52 | OK 4 | 2011-10-26 21:23:52 | OK 5 | 2011-10-26 22:23:52 | BAD
I think this is what you’re looking for: