Sequence within SQL Select

后端 未结 3 1030
旧时难觅i
旧时难觅i 2021-02-15 15:51

I\'m having a bit of a problem with using my sequence within a SELECT statement.

SELECT
     c.cust_name,
     c.site,
     customer_id_seq.nextval         


        
3条回答
  •  长情又很酷
    2021-02-15 16:30

    You cannot use sequences in queries with ORDER BY.

    Remove the ORDER BY or put in into a subquery:

    SELECT  q.*, customer_id_seq.nextval    
    FROM    (
            SELECT  c.cust_name,
                    c.site
            FROM    customer c
            WHERE   c.customer_id IS NULL
            ORDER BY
                    c.site_code ASC
            ) q
    

提交回复
热议问题