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 t (id char, cal1 int); insert into t values ('a', 1), ('b', 0),('a', 2),('c', 1),('a', 3); SELECT top 2 MIN(id) id FROM t GROUP by id ORDER BY NEWID(); select * from t where id in ( SELECT top 2 MIN(id) id FROM t GROUP by id ORDER BY NEWID() );

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

Copy Clear