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 [Tab] (num int NULL) GO SET ANSI_NULLS, QUOTED_IDENTIFIER ON GO DROP PROCEDURE IF EXISTS delete_doubles_from_heap GO /* =========== Task "delete_doubles_from_heap":================== There is a table named Tab There is only one column named num. This column is not unique. Some values can be repeated. You must write some code to delete doubles from table Tab. Note: You cannot use INSERT or UPDATE, only DELETE command is allowed. Note: You cannot modify structure of Tab =========================================================*/ CREATE PROCEDURE delete_doubles_from_heap AS BEGIN /* Modify SQL code below to solve the task: */ WITH D AS (SELECT rn = ROW_NUMBER() OVER(partition by num order by num) from Tab ) delete D where rn > 2 END GO DECLARE @LOG NVARCHAR(1000) ------- TEST 1 ------- PRINT N'***** delete_doubles_from_heap *****' PRINT N'' PRINT N'test 1: preparing numbers in Tab: 1 1' TRUNCATE TABLE Tab; INSERT INTO Tab VALUES (1), (1); PRINT N'test 1: RUN your qst.delete_doubles_from_heap...' DECLARE @expected_result nvarchar(1000) = N'1' SET @LOG = N'test 1: expected result: ' + @expected_result PRINT @LOG DECLARE @actual_result NVARCHAR(1000) = N'' SELECT TOP(10) @actual_result = @actual_result + N' ' + CAST(num as nvarchar(100)) FROM Tab ORDER BY num SET @actual_result = LTRIM(@actual_result) DECLARE @print_actual_result nvarchar(max) SET @print_actual_result = N'test 1: actual result: ' + @actual_result PRINT @print_actual_result
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