Dhruv
Dhruv

Reputation: 1728

How to count different values in one column of table in Oracle 10g?

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?

Upvotes: 1

Views: 11445

Answers (3)

Samir
Samir

Reputation: 6605

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

Upvotes: 0

Sachin Shanbhag
Sachin Shanbhag

Reputation: 55489

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

Upvotes: 5

Justin Cave
Justin Cave

Reputation: 231671

It sounds like you want a GROUP BY

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

Upvotes: 9

Related Questions