【发布时间】:2013-05-07 09:21:24
【问题描述】:
我目前在 TSQL 中可以正常运行以下脚本:
select v.ratings as [Rating], COUNT(*) as 'total',
CAST(count(*)*100.0/tot as decimal(12,1)) as 'percent'
from (select (case when Ratings = 5 then '5'
when Ratings = 6 then '6'
when Ratings = 7 then '7'
end) as Ratings,
COUNT(*) over (partition by NULL) as tot
from vHighPerformance) v
group by v.Ratings, v.tot
这个相同的脚本在 MYSQL 中不起作用。它给出了以下内容: 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以获取正确的语法,以便在 '[Rating], COUNT() as 'total' 附近使用,CAST(count(*)100.0/tot as decimal(12 ,1)) 作为 '' 在第 1 行
有没有人有任何关于把它翻译成 mysql 的建议?由于我的研究不足。提前致谢。
【问题讨论】:
标签: mysql tsql casting partitioning