【发布时间】:2020-12-13 01:52:24
【问题描述】:
我在 MySQL 沙盒环境中工作并出现运行时错误:“字段列表”中的未知列“tab.maxid”。 这是我的原始代码:
with tab as(
select max(id) as maxid from seat)
select id,
CASE
WHEN (id % 2 <> 0 and id = tab.maxid) THEN student
WHEN (id % 2 <> 0 and id < tab.maxid) THEN lead(student) over(order by id)
ELSE lag(student) over(order by id)
END AS `student`
from seat;
我做错了什么?感谢您的帮助!
【问题讨论】:
标签: case common-table-expression