Oracle SQL Select中的行数? [英] Number of rows in Oracle SQL Select?

查看:142
本文介绍了Oracle SQL Select中的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道在oracle的select中返回了多少条记录.目前,我有两个查询:

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;

我需要知道COUNT,但是我不想做两个查询.有办法吗?

I need to know the COUNT but I hate doing two queries. Is there a way to do:

SELECT * FROM MY_ITEMS 

然后找出其中有多少条记录?

and then find out how many records are in there?

推荐答案

有没有办法做

Is there a way to do:

SELECT * FROM MY_ITEMS 

然后找出其中有多少条记录?

and then find out how many records are in there?

如果您希望它以这种精确的顺序排列,则可以在客户端上获取所有记录并计算它们的数量(几乎所有客户端库都为此提供了功能).

If you want it to be in this exact order, you can fetch all records on the client and count their number (almost all client libraries provide a function for that).

您也可以这样做:

SELECT  i.*, COUNT(*) OVER ()
FROM    my_items i

,它将返回您的计数以及每条记录.

, which will return you the count along with each record.

这篇关于Oracle SQL Select中的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆