By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE table1 (`Student_ID` INTEGER, `Status_Complete` TEXT, `Status_Date` TEXT, `Status_Time` TEXT, `Code` TEXT);
✓
INSERT INTO table1 (`Student_ID`, `Status_Complete`, `Status_Date`, `Status_Time`, `Code`) VALUES
('1', 'yes', '2021-03-03', '00:00:00', 'N09'),
('2', 'yes', '2021-04-03', '10:03:10', 'N09'),
('2', 'yes', '2021-04-03', '10:03:10', 'M33'),
('3', 'yes', '2021-04-03', '01:00:10', 'N09'),
('3', 'yes', '2021-04-03', '01:00:10', 'Y03'),
('3', 'yes', '2021-04-03', '01:00:10', 'B55');
✓
CREATE TABLE table2 AS
SELECT Student_ID, Status_Complete,
MIN(Status_Date) Status_Date,
TIME(MIN(Status_Date || ' ' || Status_TIME)) Status_TIME,
SUM(Status_Complete = 'yes') count,
GROUP_CONCAT(Code) Codes
FROM table1
GROUP BY Student_ID
HAVING SUM(Code = 'N09' AND Status_Complete = 'yes') > 0
ORDER BY Student_ID;
✓
SELECT * FROM table2;
Student_ID | Status_Complete | Status_Date | Status_TIME | count | Codes |
---|---|---|---|---|---|
1 | yes | 2021-03-03 | 00:00:00 | 1 | N09 |
2 | yes | 2021-04-03 | 10:03:10 | 2 | N09,M33 |
3 | yes | 2021-04-03 | 01:00:10 | 3 | N09,Y03,B55 |