Oracle 10g中如何统计表中某一列的不同值?

发布于 2024-12-01 00:04:50 字数 195 浏览 3 评论 0原文

我遇到一种情况,我必须计算表的一列中相同类型的字符串数量,例如。一列的值如下:-

apple,apple,apple,orange,orange,banana,banana,banana,banana

所以我需要计算相同类型的所有字符串,这意味着查询应该给出苹果的计数结果 3,橙子 2 个,香蕉 4 个。

偶像可以查询什么?

I have a situation where i have to count number of strings of same type in one column of a table, for eg. a column would be having values such as :-

apple, apple, apple, orange,orange, banana, banana, banana, banana

So i need to count all the strings of same type, that means query should give count result 3 for apples, 2 for oranges and 4 for banana.

What can be idol query for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

分开我的手 2024-12-08 00:04:50

听起来你想要一个GROUP BY

SELECT column_name, count(*) 
  FROM table_name
 GROUP BY column_name

It sounds like you want a GROUP BY

SELECT column_name, count(*) 
  FROM table_name
 GROUP BY column_name
送你一个梦 2024-12-08 00:04:50

您可以使用 GROUP BY -

select columnName, count(*) from tableName
group by columnName

这将为您提供该列中有多少个苹果、橙子、香蕉的结果

You can use GROUP BY -

select columnName, count(*) from tableName
group by columnName

This will give you the results of how many apples, orange, banana are there in that column

天煞孤星 2024-12-08 00:04:50

我的需要是具有不同值的同一列的计数

SELECT durum_id, count(*)   FROM kontrol WHERE tarih='2017 2 28' and tur_id=2 GROUP BY durum_id

在此处输入图像描述

My need was count of same column with different values

SELECT durum_id, count(*)   FROM kontrol WHERE tarih='2017 2 28' and tur_id=2 GROUP BY durum_id

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文