F
Filament2mo ago
mxc

table insists on "group by id" if "group by" used -> due to auto appendage of orderBy("id")

Hi all, I am having a challenge with what seems like a simple task. I am trying to create a table off of a query that uses "group by". When the page is displayed I get an error that: Grouping error: 7 ERROR: column "vendor.id" must appear in the GROUP BY clause or be used in an aggregate function protected function getTableQuery(): Builder { return Vendor::query() ->select( 'name', DB::raw('count(first) as first'), DB::raw('count(second) as second'), DB::raw('count(third) as third') ) ->groupBy('name') ->orderBy('first'); } This would make the entire group by irrelevant as I am grouping by id. will result in no grouping This appears to be the result of filament helpfully appending "order by id" I have tried using "min(id) as id", I have tried aliasing name to id and still nothing. Surely this should be simple to accomplished but its benn several hours and no progress.? Any help appreciated.
2 Replies
NolanN
NolanN3w ago
This worked for me. Thanks!

Did you find this page helpful?