SELECT
this,
query,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(rocks AS CHAR) ORDER BY _date), ',', 1 ) as top,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(rocks AS CHAR) ORDER BY _date DESC), ',', 1 ) as bottom
FROM database
SELECT
this,
query,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(rocks AS CHAR) ORDER BY _date), ',', 1 ) as top,
SUBSTRING_INDEX(GROUP_CONCAT(CAST(rocks AS CHAR) ORDER BY _date DESC), ',', 1 ) as bottom
FROM database