I have a table like this:
id make model year
1 chevy camaro 1969
2 chevy camaro 1967
3 ford mustang 1967
4 chevy corvette 1984
5 pontiac gto 1971
6 pontiac grandam 1987
I want to return a recordset that includes one row (all columns) for each distinct value in make. Example of results:
1 chevy camaro 1969
3 ford mustang 1967
5 pontiac gto 1971
Order is not important to me; it does not need to be deterministic. This is so I can easily select out example data for different use cases without having to send the entire table contents to a developer.
In MySQL, you may be able to get away with:
With most other SQL DBMS, you’d probably do:
The choice of aggregate is up to you; MAX springs to mind as a valid, deterministic alternative.