> you can't tell whether the x you get is related to the max or the min of the group Of course you can. Just ``` SELECT 'min', x, min(y) FROM foo GROUP BY (x/10) UNION ALL SELECT 'max', x, max(y) FROM foo GROUP BY (x/10); ``` I used 'min' and 'max' for illustrative purpose. Could use 0 and 1 too. Note the `UNION ALL`, to avoid an unnecessary sort+dedup, which I suspect if not what you wanted, since then you could have fewer than 2x group rows with just `UNION`.