1

I'm working on a Lumen project and I'm stumped getting this to work. This is my first project in php using Lumen. I tested the query on Workbench and get the correct result but I have no idea how to get it to work.

with top as
(
    select tbl.*, row_number() over (partition by sensor order by timestamp desc) as parted from sometable as tbl
)
select * from top where parted <=3

working through the Laravel query builder documentation as well as using other similar questions to get it to work. This gets me close:

$result = Mydb::select(DB::raw("* row_number() over (partition by sensor order by timestamp desc) as parted"))
->get()->where('parted', '<=', 3);

But the json is poorly formatted with some added index I don't know where it comes from.

0 Answers0