Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlsrv and groupBy #46

Open
bdpsoft opened this issue Dec 8, 2023 · 0 comments
Open

sqlsrv and groupBy #46

bdpsoft opened this issue Dec 8, 2023 · 0 comments

Comments

@bdpsoft
Copy link

bdpsoft commented Dec 8, 2023

You can replace in aggregate this line
->groupBy(DB::raw($this->getSqlDate())) // ->groupBy($this->dateAlias)

and add Adapter for sqlsrv

class MssqlAdapter extends AbstractAdapter
{
public function format(string $column, string $interval): string
{
$format = match ($interval) {
'minute' => 'yyyy-MM-dd HH:mm:00',
'hour' => 'yyyy-MM-dd HH:00:00',
'day' => 'yyyy-MM-dd',
'month' => 'yyyy-MM',
'year' => 'yyyy',
default => throw new Error('Invalid interval.'),
};

    return "format({$column}, '{$format}')";
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant