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 TMP1; create table TMP1 ( Клиент int, Дата date, Сумма int, Порог int ); insert into TMP1 ( Клиент, Дата, Сумма, Порог ) values (1, '20220201', 5000, 0), (1, '20220202', 10000, 0), (1, '20220203', 5000, 0), (1, '20220204', 36000, 0), (1, '20220205', 17000, 0), (1, '20220206', 100000, 0), (1, '20220207', 33445, 0), (2, '20220104', 700, 0), (2, '20220105', 400, 0), (2, '20220106', 850, 0), (2, '20220107', 50, 0), (2, '20220108', 1000, 0); select * from TMP1; drop function if exists [last3]; CREATE function [last3](@kl int, @dt date) returns integer as Begin return( SELECT SUM(q1.SUMMA) FROM ( SELECT TOP 3 [СУММА] AS SUMMA FROM TMP1 WHERE [КЛИЕНТ] = @KL AND [ДАТА] <= @DT ORDER BY [СУММА] DESC ) q1 ) End; SELECT Клиент, Дата, Сумма, [dbo].last3(Клиент, Дата) Порог from TMP1; go update TMP1 set Порог = [dbo].last3(Клиент, Дата) go select * from TMP1
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