0

I currently have the following script working fine in 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

This same script does not work in MYSQL. It gives the following: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Rating], COUNT() as 'total', CAST(count(*)100.0/tot as decimal(12,1)) as '' at line 1

Does anyone have any advice on translating this to mysql? As my research is falling short. thanks in advance.

0

1 Answer 1

0

I don't have a mysql installation to try, but this should work:

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,
                (SELECT COUNT(*) FRMO vHighPerformance) as tot
            from vHighPerformance) v
group by v.Ratings, v.tot
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.