Such as this one:
SELECT id, count( * ) , company
FROM jobs
GROUP BY company
Where id is the primary key of jobs
Such as this one:
SELECT id, count( * ) , company
FROM jobs
GROUP BY company
Where id is the primary key of jobs
Similar question:
This is MySQL specific, and is not ANSI standard SQL. Most other database engines do not allow columns on which is not being grouped or being run through an aggregate function.
It seems MySQL retains the value of the first row that matches the criteria.
The aggregate function that has this behaviour is FIRST(), and although MySQL implements it, this seems to be default behaviour for columns that are not grouped on, and which are not run through any other aggregate function.
In ANSI standard SQL you would do:
SELECT FIRST(jobtitle), company FROM jobs GROUP BY company;
Whereas in MySQL you could just (however the ANSI standard works just aswell):
SELECT jobtitle, company FROM jobs GROUP BY company;