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
with a as ( select 'red' as color union all select 'yellow' as color union all select 'green' as color union all select 'meow' as color union all select 'test' as color union all select 'black' as color union all select 'white' as color ) select c1, c2 from ( select a.color c1, b.color c2 --, a.n, b.n, a.n + b.n summ, a.n * b.n mult , (a.n * b.n) * (a.n + b.n) + (a.n + b.n) total_value , row_number() over(partition by (a.n * b.n) * (a.n + b.n) + (a.n + b.n) order by (a.n * b.n) * (a.n + b.n) + (a.n + b.n)) n from ( select color, row_number() over(order by color) n from a ) a cross join (select color, row_number() over(order by color) n from a) b where a.n != b.n ) t where n = 1 order by c1, c2

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

Copy Clear