SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
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() ); SELECT top 2 id FROM t GROUP by id ORDER BY NEWID(); select * from t where id in ( SELECT top 2 id FROM t GROUP by id ORDER BY NEWID() );
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear