Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE tbl (timestamp int, name char); INSERT INTO tbl VALUES (20221006050109, 'A'); INSERT INTO tbl VALUES (20221006050109, 'B'); INSERT INTO tbl VALUES (20221006050109, 'C'); INSERT INTO tbl VALUES (20221006050109, 'D'); INSERT INTO tbl VALUES (20221007050125, 'E'); INSERT INTO tbl VALUES (20221007050125, 'F'); INSERT INTO tbl VALUES (20221007050125, 'G'); INSERT INTO tbl VALUES (20221007050125, 'H'); WITH ranked AS ( SELECT timestamp, name, RANK() OVER (ORDER BY timestamp DESC) rnk FROM tbl ) SELECT * FROM ranked WHERE rnk = 1;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear