problem with model

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

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

The error that i received:

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

How i can build correct this query? Thanks



19.5k

Try this (I assume datafinaliza is a column):

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