© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
👑 João

GroupBy Table Widget

Hi, anyone can help me with a table widget? I want to group by "bairros" and show it, but I get this error:

Embaixador::query()
  ->select('bairro', DB::raw('COUNT(*) as total'))
  ->groupBy('bairro')
  ->orderByDesc('total')
  ->limit(5)
Embaixador::query()
  ->select('bairro', DB::raw('COUNT(*) as total'))
  ->groupBy('bairro')
  ->orderByDesc('total')
  ->limit(5)


SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'f3x_charbel.embaixadores.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

select `bairro`, COUNT(*) as total from `embaixadores` group by `bairro` order by `total` desc, `embaixadores`.`id` asc limit 11 offset 0
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'f3x_charbel.embaixadores.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

select `bairro`, COUNT(*) as total from `embaixadores` group by `bairro` order by `total` desc, `embaixadores`.`id` asc limit 11 offset 0


I think it's trying to get the id to sort, but dont have id column after groupBy
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Table widget
FilamentFFilament / ❓┊help
15mo ago
Widget Table
FilamentFFilament / ❓┊help
3y ago
Table record with GroupBy statement
FilamentFFilament / ❓┊help
3y ago
Table Widget table width ?
FilamentFFilament / ❓┊help
3y ago