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
DROP TABLE IF EXISTS clients; CREATE TABLE clients ( id number(10), name varchar2(1000), place_of_birth varchar2(2000), date_of_birth date, address varchar2(2000), passport varchar2(1000), CONSTRAINT clients_pk primary key (id) ); DROP TABLE IF EXISTS products; CREATE TABLE products ( id number(10), product_type_id number(10), name varchar2(1000), client_ref number(10), open_date date, close_date date, CONSTRAINT products_pk primary key (id) ); DROP TABLE IF EXISTS product_type; CREATE TABLE product_type ( id number(10), name varchar2(100), begin_date date, end_date date, tarif_ref number(10), CONSTRAINT product_type_pk primary key (id) ); DROP TABLE IF EXISTS accounts; CREATE TABLE accounts ( id number(10), name varchar2(1000), saldo number(10,2), client_ref number(10), open_date date, close_date date, product_ref number(10), acc_num varchar2(25), CONSTRAINT accounts_pk primary key (id) ); DROP TABLE IF EXISTS records; CREATE TABLE records ( id number(10), dt number(1), sum number(10,2), acc_ref number(10), oper_date date, CONSTRAINT records_pk primary key (id) ); DROP TABLE IF EXISTS tarifs; CREATE TABLE tarifs ( id number(10), name varchar2(1000), cost number (10,2), CONSTRAINT tarifs_pk primary key (id) ); ALTER TABLE products ADD CONSTRAINT prod_cl_fk FOREIGN KEY (client_ref) REFERENCES clients(id); ALTER TABLE products ADD CONSTRAINT prod_prodtype_fk FOREIGN KEY (product_type_id) REFERENCES product_type(id); ALTER TABLE product_type ADD CONSTRAINT product_type_fk FOREIGN KEY (tarif_ref) REFERENCES tarifs(id); ALTER TABLE records ADD CONSTRAINT rec_acc_fk FOREIGN KEY (acc_ref) REFERENCES accounts(id); ALTER TABLE accounts ADD CONSTRAINT acc_cl_fk FOREIGN KEY (client_ref) REFERENCES clients(id); ALTER TABLE accounts ADD CONSTRAINT acc_prod_fk FOREIGN KEY (product_ref) REFERENCES products(id); insert into tarifs values (1,'Тариф за выдачу кредита', 10); insert into tarifs values (2,'Тариф за открытие счета', 10); insert into tarifs values (3,'Тариф за обслуживание карты', 10); insert into product_type values (1, 'КРЕДИТ', to_date('01.01.2018','DD.MM.YYYY'), null, 1); insert into product_type values (2, 'ДЕПОЗИТ', to_date('01.01.2018','DD.MM.YYYY'), null, 2); insert into product_type values (3, 'КАРТА', to_date('01.01.2018','DD.MM.YYYY'), null, 3); insert into clients values (1, 'Сидоров Иван Петрович', 'Россия, Московская облать, г. Пушкин', to_date('01.01.2001','DD.MM.YYYY'), 'Россия, Московская облать, г. Пушкин, ул. Грибоедова, д. 5', '2222 555555, выдан ОВД г. Пушкин, 10.01.2015'); insert into clients values (2, 'Иванов Петр Сидорович', 'Россия, Московская облать, г. Клин', to_date('01.01.2001','DD.MM.YYYY'), 'Россия, Московская облать, г. Клин, ул. Мясникова, д. 3', '4444 666666, выдан ОВД г. Клин, 10.01.2015'); insert into clients values (3, 'Петров Сиодр Иванович', 'Россия, Московская облать, г. Балашиха', to_date('01.01.2001','DD.MM.YYYY'), 'Россия, Московская облать, г. Балашиха, ул. Пушкина, д. 7', '4444 666666, выдан ОВД г. Клин, 10.01.2015'); insert into products values (1, 1, 'Кредитный договор с Сидоровым И.П.', 1, to_date('01.06.2015','DD.MM.YYYY'), null); insert into products values (2, 2, 'Депозитный договор с Ивановым П.С.', 2, to_date('01.08.2017','DD.MM.YYYY'), null); insert into products values (3, 3, 'Карточный договор с Петровым С.И.', 3, to_date('01.08.2017','DD.MM.YYYY'), null); insert into accounts values (1, 'Кредитный счет для Сидоровым И.П.', -2000, 1, to_date('01.06.2015','DD.MM.YYYY'), null, 1, '45502810401020000022'); insert into accounts values (2, 'Депозитный счет для Ивановым П.С.', 6000, 2, to_date('01.08.2017','DD.MM.YYYY'), null, 2, '42301810400000000001'); insert into accounts values (3, 'Карточный счет для Петровым С.И.', 8000, 3, to_date('01.08.2017','DD.MM.YYYY'), null, 3, '40817810700000000001'); insert into records values (1, 1, 5000, 1, to_date('01.06.2015','DD.MM.YYYY')); insert into records values (2, 0, 1000, 1, to_date('01.07.2015','DD.MM.YYYY')); insert into records values (3, 0, 2000, 1, to_date('01.08.2015','DD.MM.YYYY')); insert into records values (4, 0, 3000, 1, to_date('01.09.2015','DD.MM.YYYY')); insert into records values (5, 1, 5000, 1, to_date('01.10.2015','DD.MM.YYYY')); insert into records values (6, 0, 3000, 1, to_date('01.10.2015','DD.MM.YYYY')); insert into records values (7, 0, 10000, 2, to_date('01.08.2017','DD.MM.YYYY')); insert into records values (8, 1, 1000, 2, to_date('05.08.2017','DD.MM.YYYY')); insert into records values (9, 1, 2000, 2, to_date('21.09.2017','DD.MM.YYYY')); insert into records values (10, 1, 5000, 2, to_date('24.10.2017','DD.MM.YYYY')); insert into records values (11, 0, 6000, 2, to_date('26.11.2017','DD.MM.YYYY')); insert into records values (12, 0, 120000, 3, to_date('08.09.2017','DD.MM.YYYY')); insert into records values (13, 1, 1000, 3, to_date('05.10.2017','DD.MM.YYYY')); insert into records values (14, 1, 2000, 3, to_date('21.10.2017','DD.MM.YYYY')); insert into records values (15, 1, 5000, 3, to_date('24.10.2017','DD.MM.YYYY')); SELECT acc_num FROM clients INNER JOIN accounts ON clients.id = accounts.client_ref INNER JOIN products ON products.client_ref = clients.id INNER JOIN product_type ON products.product_type_id=product_type.id WHERE product_type.name in ('ДЕПОЗИТ','КАРТА'); SELECT oper_date, dt, COALESCE(SUM(SUM),0) AS Summa FROM records group by oper_date, dt;
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