Number of rows in Oracle SQL Select?

前端 未结 4 620
时光取名叫无心
时光取名叫无心 2021-02-08 02:18

I need to know how many records were returned in a select in oracle. Currently, I do two queries:

SELECT COUNT(ITEM_ID) FROM MY_ITEMS;

SELECT * FROM MY_ITEMS;
         


        
4条回答
  •  既然无缘
    2021-02-08 03:00

    This ought to do the trick.

    WITH 
    base AS
    (
        SELECT *
        FROM MY_ITEMS
    )
    SELECT (SELECT COUNT(*) FROM base) kount,
           base.*
    FROM base
    

提交回复
热议问题