Number of rows in Oracle SQL Select?

前端 未结 4 679
时光取名叫无心
时光取名叫无心 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:02

    I'm just unsure about the table aliases, I don't remember in Oracle if they require 'AS' or not. But this should work.

    select mt.*, c.Cntr
        from MyTable mt
            , (select COUNT(*) as Cntr
                   from MyTable
               ) c
    

提交回复
热议问题