doushangxianq07480 2016-06-29 00:24
浏览 120
已采纳

#1064 - 您的SQL语法出错 - RANK FUNCTION

SELECT RANK() OVER (ORDER BY `point`) FROM `user`

This is my query, I excute it in phpmyadmin, and receive the message:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(ORDER BY `point`) FROM `user` LIMIT 0, 30' at line 1"

I try to find the error but just can't. Please help me!

  • 写回答

1条回答 默认 最新

  • douzai1074 2016-06-29 00:25
    关注

    MariaDB doesn't support window functions. You can do this using a correlated subquery:

    SELECT u.*,
           (SELECT 1 + COUNT(*)
            FROM user u2
            WHERE u2.point < u.point
           ) as rank
    FROM `user` u;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试