SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
DROP TABLE IF EXISTS Directors; CREATE TABLE Directors ( id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(40), surname VARCHAR(40), email VARCHAR(40) ); TRUNCATE Directors; INSERT INTO Directors (name, surname, email) VALUES ('Christopher', 'Nolan', 'chris@gmail.com'), ('Steven', 'Spielberg', 'sspil@outlook.com'), ('Quentin', 'Tarantino', 'queen@gmail.com'), ('Martin', 'Scorsese', 'martins@outlook.com'), ('David', 'Fincher', 'dfincher@outlook.com'), ('Ridley', 'Scott', 'riddler@gmail.com'), ('Stanley', 'Kubrick', 'bigstan@icloud.com'), ('Clint', 'Eastwood', 'cowboy@yahoo.com'), ('James', 'Cameron', 'jamesava@yahoo.com'), ('Tim', 'Burton', 'timmy@icloud.com'); SELECT SUBSTRING_INDEX(email, '@', -1) AS domain, GROUP_CONCAT(SUBSTRING_INDEX(email, '@', 1) ORDER BY email SEPARATOR ', ') AS local FROM Directors GROUP BY email --WHERE country != 'USA' --TIME(order_time) = GREATEST(TIME_TO_SEC(order_time))days_spent --ORDER BY num_of_names, letter --LIMIT 1

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear