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 Device ( Id int IDENTITY(1, 1) NOT NULL PRIMARY KEY, Name varchar(50) NOT NULL, DeviceTypeId int NOT NULL ) CREATE TABLE MeasuredUsage ( Id int IDENTITY(1, 1) NOT NULL PRIMARY KEY, DeviceId int NOT NULL FOREIGN KEY REFERENCES Device ( Id ), StartTimeUtc datetime NOT NULL, Gallons float NOT NULL ) INSERT INTO Device ( Name, DeviceTypeId ) VALUES ('Pump Room', 1), ('Cooling Tower 1', 2), ('Sports Field', 1), ('Kitchen', 3), ('Cooling Tower 2', 2), ('Water Tower', 1) INSERT INTO MeasuredUsage ( DeviceId, StartTimeUtc, Gallons ) VALUES (1, '2024-02-05 10:00', 123), (1, '2024-02-05 11:00', 75), (1, '2024-02-06 10:00', 88), (1, '2024-02-07 10:00', 32), (1, '2024-02-07 11:00', 12), (2, '2024-02-05 10:00', 23), (2, '2024-02-05 11:00', 34), (2, '2024-02-05 12:00', 55), (2, '2024-02-06 10:00', 77), (2, '2024-02-06 11:00', 86), (3, '2024-02-05 10:00', 31), (3, '2024-02-05 11:00', 44), (3, '2024-02-07 10:00', 68), (3, '2024-02-07 11:00', 32), (3, '2024-02-07 12:00', 13), (4, '2024-02-05 10:00', 44), (4, '2024-02-05 11:00', 53), (4, '2024-02-06 10:00', 79), (4, '2024-02-06 11:00', 80), (5, '2024-02-06 12:00', 756), (5, '2024-02-06 13:00', 59), (5, '2024-02-07 10:00', 33), (5, '2024-02-07 11:00', 34), (6, '2024-02-05 10:00', 64), (6, '2024-02-05 11:00', 46), (6, '2024-02-06 12:00', 596) UPDATE Device SET Name = Name + ' [' + LTRIM(STR(DeviceTypeId)) + ']' SELECT d.Id, d.Name, SUM(u.Gallons) AS TotalGallons FROM Device d INNER JOIN MeasuredUsage u ON d.Id = u.DeviceId GROUP BY d.Id, d.Name ORDER BY SUM(u.Gallons) DESC SELECT d.Id, d.Name, SUM(u.Gallons) AS TotalGallons FROM Device d INNER JOIN MeasuredUsage u ON d.Id = u.DeviceId GROUP BY d.Id, d.Name HAVING SUM(u.Gallons) >= 300 ORDER BY SUM(u.Gallons) DESC
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
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