M
M
Mikha Pankratov2015-10-19 16:30:22
MySQL
Mikha Pankratov, 2015-10-19 16:30:22

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

1 answer(s)
M
Mikha Pankratov, 2015-10-19
@frmax

No brackets! []
$query->groupBy('CASE WHEN table.var > 0 THEN table.var');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question