Answer the question
In order to leave comments, you need to log in
Is it possible to use IF in Yii2 groupBy?
Good afternoon,
I need to set the conditions that if var> 0 group by one field, if not, then do not group output as is.
I'm trying something like this)) In sql I got conditions - I tried to put it in yii2...
$query->groupBy(['CASE WHEN table.var > 0 THEN table.var']);
Can anyone come across?
Answer the question
In order to leave comments, you need to log in
No brackets! []
$query->groupBy('CASE WHEN table.var > 0 THEN table.var');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question