SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
CREATE TABLE wi (uid INT, start text, stop text); INSERT INTO wi VALUES (1, '17.01.2020 11:34', '17.01.2020 11:43'); INSERT INTO wi VALUES (1, '17.01.2020 11:43', '17.01.2020 11:59'); INSERT INTO wi VALUES (1, '17.01.2020 12:25', '17.01.2020 12:47'); INSERT INTO wi VALUES (1, '17.01.2020 16:48', '17.01.2020 17:11'); INSERT INTO wi VALUES (1, '17.01.2020 17:16', '17.01.2020 17:20'); INSERT INTO wi VALUES (2, '17.01.2020 17:22', '17.01.2020 17:40'); INSERT INTO wi VALUES (2, '17.01.2020 17:26', '17.01.2020 17:40'); INSERT INTO wi VALUES (2, '17.01.2020 18:38', '17.01.2020 18:41'); INSERT INTO wi VALUES (2, '17.01.2020 18:39', '17.01.2020 18:58'); INSERT INTO wi VALUES (2, '17.01.2020 19:01', '17.01.2020 19:12'); select uid, start, stop, if(timestampdiff(minute, stop, lead(start) over(partition by uid)) > MINUTE('00:25:00'), 'True', 'False') as time from (SELECT uid, STR_TO_DATE(start, '%d.%m.%Y %H:%i') as start, STR_TO_DATE(stop, '%d.%m.%Y %H:%i') as stop from wi) as wifi; select uid, start, stop from(select uid, if(time = 'True' and lag(time) over(partition by uid) = 'False', lag(start) over (partition by uid), if(time = 'True' and lag(time) over(partition by uid) = 'True', start, if(time = 'False' and lag(time) over(partition by uid) = 'True', start, Null))) as start, if(time = 'True' and lag(time) over(partition by uid) = 'False', stop, if(time = 'True' and lag(time) over(partition by uid) = 'True',stop, if(time = 'False' and lead(time) over(partition by uid) = 'True', lead(time) over(partition by uid), if(time = 'False' and lead(time) over(partition by uid) = 'False', last_value(stop) over (partition by uid rows between current row and UNBOUNDED FOLLOWING), Null)))) as stop from(select uid, start, stop, if(timestampdiff(minute, stop, lead(start) over(partition by uid)) > MINUTE('00:25:00'), 'True', 'False') as time from (SELECT uid, STR_TO_DATE(start, '%d.%m.%Y %H:%i') as start, STR_TO_DATE(stop, '%d.%m.%Y %H:%i') as stop from wi) as wifi) as wifi_2) as wifi_3 where start is not Null;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear