我想做这样的事情:
select
case when (select count(*) as score from users t1 ) >5 THEN score else 0 end
当我尝试它时,我得到错误:
column score doesn't exists.
我可以用其他方式做到这一点吗?我需要它来设置一个 LIMIT 值。我当然想这样做:
select
case when (select count(*) as score from users t1 ) >5 THEN (select count(*) as score from users) else 0 end
但比我需要执行两次相同的查询。有人有什么想法吗?