DROP DATABASE IF EXISTS test;
CREATE DATABASE IF NOT EXISTS test;
USE test;
CREATE TABLE IF NOT EXISTS a
(
    b INT PRIMARY KEY
);


INSERT INTO a VALUES (1) ON DUPLICATE KEY UPDATE b = b;


SELECT 
(
    SELECT b FROM 
	 (
	 		SELECT b FROM 
					a
					  GROUP BY b
	 ) AS a1
                WHERE a1.b = a2.b
) AS result
	FROM a AS a2
			WHERE a2.b = 1
			GROUP BY a2.b;