SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE IF NOT EXISTS Lesson ( id INTEGER PRIMARY KEY AUTOINCREMENT, day INTEGER NOT NULL, index_number INTEGER NOT NULL ); INSERT INTO Lesson (day, index_number) VALUES (1, 1); INSERT INTO Lesson (day, index_number) VALUES (1, 2); INSERT INTO Lesson (day, index_number) VALUES (1, 3); INSERT INTO Lesson (day, index_number) VALUES (2, 1); INSERT INTO Lesson (day, index_number) VALUES (2, 2); INSERT INTO Lesson (day, index_number) VALUES (2, 3); SELECT day, json_agg(index_number) FROM Lesson GROUP BY day ORDER BY index_number;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear