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
with RECURSIVE month as( select date('2005-07-01') date union all select date + interval 1 day from month where date + interval 1 day <= '2005-07-31' ), rented as( select store_id ,date_format(rental_date, '%Y-%m-%d') date_ren ,count(rental_id) rented from rental r join inventory i on r.inventory_id = i.inventory_id group by store_id, date_ren ), returned as( select date_format(return_date, '%Y-%m-%d') date_ret ,store_id ,count(rental_id) returned from rental r left join inventory i on r.inventory_id = i.inventory_id group by date_ret, store_id ), s1 as( select date ,case when rented.rented is not null then rented.rented else 0 end rented_at_store_1 ,case when returned.returned is not null then returned.returned else 0 end returned_at_store_1 from month left join rented on month.date = rented.date_ren and rented.store_id = 1 left join returned on month.date = returned.date_ret and returned.store_id = 1 ), s2 as( select date ,case when rented.rented is not null then rented.rented else 0 end rented_at_store_2 ,case when returned.returned is not null then returned.returned else 0 end returned_at_store_2 from month left join rented on month.date = rented.date_ren and rented.store_id = 2 left join returned on month.date = returned.date_ret and returned.store_id = 2 ) select s1.date ,rented_at_store_1 ,returned_at_store_1 ,rented_at_store_2 ,returned_at_store_2 ,rented_at_store_1 + rented_at_store_2 total_rented ,returned_at_store_1 + returned_at_store_2 total_returned from s1 left join s2 on s2.date = s1.date ; show status like 'Last_query_cost';
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