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 EXTENSION hstore; DROP TABLE IF EXISTS tmp_h_sometable; CREATE TABLE tmp_h_sometable ( h hstore NULL, dt_created timestamp NULL DEFAULT 'now'::text::timestamp without time zone, is_init bool NULL ); INSERT INTO tmp_h_sometable (h,dt_created,is_init) VALUES ('"pos"=>"202103081156460559467695", "_ID"=>"1", "op_ts"=>"2021-03-08 08:56:46.388", "table"=>"sometable", "MAJDAT"=>"20210305", "MAJHMS"=>"115646", "op_type"=>"U"','2021-03-15 14:37:09.033001',NULL), ('"pos"=>"202103081206370559640756", "_ID"=>"2", "op_ts"=>"2021-03-08 09:06:37.280", "table"=>"sometable", "MAJDAT"=>"20210308", "MAJHMS"=>"120637", "op_type"=>"D"','2021-03-15 14:51:34.173244',NULL), ('"pos"=>"202103081212350559718333", "_ID"=>"3", "op_ts"=>"2021-03-08 09:12:35.368", "table"=>"sometable", "MAJDAT"=>"20210107", "MAJHMS"=>"121235", "op_type"=>"U"','2021-03-15 15:13:11.715818',NULL), ('"pos"=>"202103081208080559650865", "_ID"=>"2", "op_ts"=>"2021-03-08 09:08:08.358", "table"=>"sometable", "MAJDAT"=>"20210309", "MAJHMS"=>"120808", "op_type"=>"U"','2021-03-15 15:18:45.857119',NULL), ('"pos"=>"202103081206370559640764", "_ID"=>"2", "op_ts"=>"2021-03-08 09:06:37.282", "table"=>"sometable", "MAJDAT"=>"20210303", "MAJHMS"=>"120637", "op_type"=>"I"','2021-03-15 15:29:43.868558',NULL), ('"pos"=>"202103081213480559740300", "_ID"=>"3", "op_ts"=>"2021-03-08 09:13:48.156", "table"=>"sometable", "MAJDAT"=>"20210305", "MAJHMS"=>"21348", "op_type"=>"D"','2021-03-15 15:34:11.050351',NULL), ('"pos"=>"202103081155380559443438", "_ID"=>"1", "op_ts"=>"2021-03-08 08:55:38.698", "table"=>"sometable", "MAJDAT"=>"20210208", "MAJHMS"=>"115538", "op_type"=>"I"','2021-03-15 14:35:37.133757',NULL), ('"pos"=>"202103081156460559467716", "_ID"=>"1", "op_ts"=>"2021-03-08 08:56:46.395", "table"=>"sometable", "MAJDAT"=>"20210307", "MAJHMS"=>"15646", "op_type"=>"U"','2021-03-15 14:56:21.570984',NULL), ('"pos"=>"202103081207590559650549", "_ID"=>"4", "op_ts"=>"2021-03-08 09:07:59.823", "table"=>"sometable", "MAJDAT"=>"20210208", "MAJHMS"=>"20759", "op_type"=>"I"','2021-03-15 14:56:21.570984',NULL), ('"pos"=>"202103081205400559617061", "_ID"=>"4", "op_ts"=>"2021-03-08 09:05:40.488", "table"=>"sometable", "MAJDAT"=>"20210301", "MAJHMS"=>"120540", "op_type"=>"I"','2021-03-15 15:29:33.790932',NULL); SELECT * FROM tmp_h_sometable; SELECT * FROM (SELECT _id, table_name, ts, op_ts, op_type, row_number()over(partition by _id, table_name order by op_ts) as rn FROM (SELECT (tmp_h_sometable.h -> '_ID') as _id, (tmp_h_sometable.h -> 'table') as table_name, (tmp_h_sometable.h -> 'op_ts') as op_ts, to_timestamp((tmp_h_sometable.h -> 'MAJDAT') || lpad((tmp_h_sometable.h -> 'MAJHMS'),6,'0'),'yyyymmddhh24miss')::timestamptz as ts, (tmp_h_sometable.h -> 'op_type') as op_type FROM tmp_h_sometable) tmp1) tmp2 WHERE rn = 1 or op_type<>'D';
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