Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE USERINFO ( USERID INT, USERNAME VARCHAR(64) ) INSERT INTO USERINFO VALUES (1, 'USER_1'); CREATE TABLE acc_monitor_log ( pin INT, time DATETIME ); INSERT INTO acc_monitor_log VALUES (1, CONVERT(DATETIME,'2023-09-30 12:32:00')), (1, CONVERT(DATETIME,'2023-09-30 19:13:14')), (1, CONVERT(DATETIME,'2023-10-01 10:10:44')), (1, CONVERT(DATETIME,'2023-10-01 12:13:14')); SELECT USERID, USERNAME, MIN(time) , MAX(time) FROM USERINFO JOIN acc_monitor_log ON acc_monitor_log.pin = USERID WHERE [USERID] = 1 GROUP BY USERID, USERNAME, CAST(time AS DATE) ORDER BY CAST(time AS DATE) ASC;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear