Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

Viewed 370

I know there are tons of question that includes that error, but I haven't seen one that incldues a subquery with row_numbers.

Ok so I have this raw query which WORKS when I run directly on a database management application (I use sequel pro)

The ff info was actually taken from my previous question:

I ended up having this query

select * from (select *, ROW_NUMBER() OVER(PARTITION BY type ORDER BY id) AS seqnum from `example`) as `t` where `seqnum` <= 50

This query works perfectly on sequel pro (database management application)

but when I do (wrap it on DB::statement in laravel):

DB::statement("select * from (select *, ROW_NUMBER() OVER(PARTITION BY type ORDER BY id) AS seqnum from `example`) as `t` where `seqnum` <= 50");

On Laravel I get:

Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

Any ideas why did it failed on laravel but was ok on a database management app?

1 Answers
Related