SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
drop table emp_input; create table emp_input ( id int, name varchar(40) ); insert into emp_input values (1, 'Emp1'); insert into emp_input values (2, 'Emp2'); insert into emp_input values (3, 'Emp3'); insert into emp_input values (4, 'Emp4'); insert into emp_input values (5, 'Emp5'); insert into emp_input values (6, 'Emp6'); insert into emp_input values (7, 'Emp7'); insert into emp_input values (8, 'Emp8'); select * from emp_input; with cte as ( select concat(id,' ',name) as id, ntile(4) over(order by id) as buckets from emp_input) select string_agg(id,', ') over(partition by buckets) from cte group by buckets
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear