title: Mysql rank over function
body: <p>I am using the below query in MySQL workbench, and I am getting an error near the rank over function. I think MySQL may not support support Rank() over function. hence please can anyone help to run this one successfully?</p>
  
  <pre><code>select STORE_CODE, 'GBP', "SALES WITHOUT VAT", 'UK' from(
  select STORE_CODE, "SALES WITHOUT VAT", RANK() OVER(ORDER BY "SALES WITHOUT VAT" DESC) AS RANK 
   from( select store_code, sum("SALES WITHOUT VAT") as "SALES WITHOUT VAT" 
         from( select c_site AS STORE_CODE, case when c_currency = 'GBP' then A_SALES_EXVAT_REAL 
         when c_currency = 'EUR' then round(A_SALES_EXVAT_REAL * ukurs ,3) end as "SALES WITHOUT VAT" 
         from kf_move01.salesticket_line left outer join
         (select ukurs, to_date(99999999-gdatu), year(to_date(99999999-gdatu)) as year, month(to_date(99999999-gdatu)) as month 
         from "KF_MOVE01"."TCURR" 
         where mandt = 201 and kurst = 'M' and tcurr = 'GBP' and fcurr = 'EUR' 
         order by 99999999-gdatu desc) as tcur 
         on tcur.year = year(d_year_month_day) and tcur.month = month(d_year_month_day) 
         where id_opco = 2 and c_comp_code in ('BQ10', 'BQ20','BQ30','BQ40') 
         and d_year_month_day between add_days(now(),-181) and add_days(now(),-1)) 
         group by store_code 
         order by 2 desc ) ) where rank &lt;= 5;
  </code></pre>
  
  <blockquote>
    <p>Error Code: 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 '( ORDER BY "SALES WITHOUT VAT" DESC ) FROM (SELECT' at line 6 0.000 sec Java error: SAP DBTech JDBC: [279] (at 179): group function is nested: line 1 col 180 (at pos 179) </p>
  </blockquote>
  
  <p>Online sql checker error: </p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; it seems the error is around: '( ORDER BY "SALES WITHOUT VAT" DESC ) AS RANK from( ' at line 10</p>
  </blockquote>