Suppose I'm selecting from some tables using a GROUP BY clause:
SELECT brand, model, year, color FROM cars
WHERE cost > 2000
AND cost < 500000
GROUP BY brand
Suppose further that my 'cars' table has 20 different records with 'aston martin' as their brand but with varying model, year, and colors. Given that this query returns only one record for each brand, what values will show up in model, year, and color?
Also, what happens when I am joining multiple tables with a GROUP BY clause...like if I had multiple drivers per car. Whose name would show up in this query:
SELECT c.brand, c.model, c.year, c.color, d.name
FROM cars c, drivers d
WHERE d.car_id=c.id
AND c.cost > 2000
AND c.cost < 500000
GROUP BY c.brand