© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•5mo ago•
19 replies
Hung Thai

Custom Aggregate Table

Hi. I'm having error on aggregate table on v4.

In v3, I can add the getTableRecordKey function and everything work just fine.
But in v4, even though I added this to resolve table record id, but it seems like the query builder still get the model id in the groupBy by the end.

Here is what i have on v4 custom table page:

class CustomPage extends Page implements HasTable
{
    use InteractWithTable;
    ...
    
    protected function getTableQuery(): Builder
    {
        return CustomsData::query()
            ->select('importer')
            ->selectRaw('COUNT(product) as total_import')
            ->selectRaw('SUM(qty) as total_qty')
            ->selectRaw('SUM(value) as total_value')
            ->groupBy('importer');
    }

    public function table....
    ...

    public function getTableRecordKey(Model|array $record): string
    {
        return uniqid();
    }
}
class CustomPage extends Page implements HasTable
{
    use InteractWithTable;
    ...
    
    protected function getTableQuery(): Builder
    {
        return CustomsData::query()
            ->select('importer')
            ->selectRaw('COUNT(product) as total_import')
            ->selectRaw('SUM(qty) as total_qty')
            ->selectRaw('SUM(value) as total_value')
            ->groupBy('importer');
    }

    public function table....
    ...

    public function getTableRecordKey(Model|array $record): string
    {
        return uniqid();
    }
}


and here is the page error it throws:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'customs_data.customs_data.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (Connection: mysql_customs_data, SQL: select `importer`, COUNT(product) as total_import, SUM(qty) as total_qty, SUM(value) as total_value from `customs_data` where (date(`import_date`) >= 2025-07-08 and date(`import_date`) <= 2025-10-08) group by `importer` order by `total_value` desc, `customs_data`.`id` asc limit 10 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 'customs_data.customs_data.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (Connection: mysql_customs_data, SQL: select `importer`, COUNT(product) as total_import, SUM(qty) as total_qty, SUM(value) as total_value from `customs_data` where (date(`import_date`) >= 2025-07-08 and date(`import_date`) <= 2025-10-08) group by `importer` order by `total_value` desc, `customs_data`.`id` asc limit 10 offset 0)


Can any body had any solution for this?
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

Custom table
FilamentFFilament / ❓┊help
7mo ago
Custom page/table
FilamentFFilament / ❓┊help
3mo ago
Custom Table Filter
FilamentFFilament / ❓┊help
5mo ago