problem with model

I have a problem when i make a query on database, following the code that i tried run:

Os::count(array("status_id != 5", "group" => "DATE_FORMAT(datafinaliza, '%Y-%m')"));

The error that i received:

Scanning error before 'DATE_FORMAT(data...' when parsing: SELECT DATE_FORMAT(datafinaliza, '%Y-%m'), COUNT(*) AS rowcount FROM [Os] WHERE status_id != 5 GROUP BY [DATE_FORMAT(datafinaliza, '%Y-%m')] (140)

How i can build correct this query? Thanks



20.4k

Try this (I assume datafinaliza is a column):

Os::count([
    "status_id != 5 GROUP BY DATE_FORMAT(datafinaliza, '%Y-%m')"
]);