mysql中怎么实现with..as操作,请大神帮忙。

select a.*,case when chances = (select max(chances)from a )then '12'else null end flag from (SELECT '1'name,FLOOR(1 + (RAND()10))chances union all SELECT '2'name,FLOOR(1 + (RAND()10))chances union all SELECT '3'name,FLOOR(1 + (RAND()10))chances )as a ...
mysql中怎么实现with..as操作,请大神帮忙。
类似这样、用子查询代替:
select
a.*,
case
when
chances
=
(
select
max(chances)
from
a
)
then
'12'
else
null
end
flag
from
(
SELECT
'1'
name,FLOOR(1
+
(RAND()
*
10))
chances
union
all
SELECT
'2'
name,FLOOR(1
+
(RAND()
*
10))
chances
union
all
SELECT
'3'
name,FLOOR(1
+
(RAND()
*
10))
chances
)
as
a2020-04-08
mengvlog 阅读 9 次 更新于 2025-07-20 07:30:16 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部