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 Transactions (ID int not null, D_DATE date, CHN_ID int not null, AMOUNT int not null, MERCH Character(20), CITY Character(20)); Insert into Transactions (ID, D_DATE, CHN_ID, AMOUNT, MERCH, CITY) Values (101, to_date('01.12.2019','DD.MM.YYYY'), 1, 100, 'Merch1', 'Moscow'), (102, to_date('04.11.2019','DD.MM.YYYY'), 2, 500, 'Merch2', 'MOSCOW'), (103, to_date('12.12.2019','DD.MM.YYYY'), 4, 700, 'Merch1', 'Samara'), (104, to_date('01.12.2019','DD.MM.YYYY'), 3, 200, 'Merch3', 'Moscow'), (105, to_date('18.12.2019','DD.MM.YYYY'), 3, 300, 'Merch3', 'SamAra'), (106, to_date('20.12.2019','DD.MM.YYYY'), 4, 500, 'Merch2', 'Volgograd'), (107, to_date('04.12.2019','DD.MM.YYYY'), 4, 400, 'Merch4', 'Moscow'), (108, to_date('07.12.2019','DD.MM.YYYY'), 4, 400, 'Merch5', 'MoScow'); Create table Merch_tariff (MERCH Character(20), CHN_ID int, TARIFF Character(20)); Insert into Merch_tariff (MERCH, CHN_ID, TARIFF) Values ('Merch1', 1, '1,2 мин. 20 руб.'), ('Merch1', NULL, '1%'), ('Merch2', NULL, '2%'), ('Merch3', 3, '1,4% мин. 12 руб.'), ('Merch4', 4, '2% макс. 50 руб.'); Select t.*, coalesce(m1.tariff, m2.tariff, 'Не найден') applied_tariff From transactions t Left outer join merch_tariff m1 On m1.merch=t.merch and m1.chn_id=t.chn_id Left outer join merch_tariff m2 On m2.merch=t.merch and m2.chn_id is 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