SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
drop table students; create table students ( id int primary key, student_name varchar(50) not null ); insert into students values (1, 'James'), (2, 'Michael'), (3, 'George'), (4, 'Stewart'), (5, 'Robin'); select id,student_name, case when id%2 <> 0 then lead(student_name,1,student_name) over(order by id) when id%2 = 0 then lag(student_name) over(order by id) end as new_student_name from students;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear