ROW_NUMBER Without ORDER BY

前端 未结 4 678
囚心锁ツ
囚心锁ツ 2020-12-28 12:52

I\'ve to add row number in my existing query so that I can track how much data has been added into Redis. If my query failed so I can start from that row no which is updated

4条回答
  •  臣服心动
    2020-12-28 13:03

    Try just order by 1. Read the error message. Then reinstate the order by (select 1). Realise that whoever wrote this has, at some point, read the error message and then decided that the right thing to do is to trick the system into not raising an error rather than realising the fundamental truth that the error was trying to alert them to.

    Tables have no inherent order. If you want some form of ordering that you can rely upon, it's up to you to provide enough deterministic expression(s) to any ORDER BY clause such that each row is uniquely identified and ordered.

    Anything else, including tricking the system into not emitting errors, is hoping that the system will do something sensible without using the tools provided to you to ensure that it does something sensible - a well specified ORDER BY clause.

提交回复
热议问题