How to query count and limit at one go

i want to query influx from kapacitor to do this
select count(testStatus) from TestAutomation where testname=‘test’ and testStatus=0 order by desc limit 3
where i want to count failures from last 3 points. How do i do that? right now this query will return total count. It will override limit.