Skip to content
Gilberto Junior edited this page Nov 29, 2019 · 3 revisions

This method agroups rows to summarize.

Sintax

public function having(string $column, string $comparator, string|int|bool|float $value): self;
public function having(string $sql): self;

Example 1

PHP's way:

$repository->having('COUNT(id)', '>', 1);

SQL's Representation:

HAVING
  COUNT(id) > 1

Example 2

PHP's way:

$repository->having('SUM(quantity) > 1000');

SQL's Representation:

HAVING
  SUM(quantity) > 1000

🡄 Group By | Sorting 🡆