Forum Moderators: coopster

Message Too Old, No Replies

occurrence of a particular record

         

ayushchd

2:08 pm on Aug 19, 2007 (gmt 0)

10+ Year Member



How can I calculate the number of times a record is occurring in a table?

For eg, this table :

----------------------------
¦..........................¦
¦S. No ¦ Company....¦
¦..........................¦
---------------------------
¦1 ¦ A
---------------------------
¦2 ¦ B
-----------------------------
¦3 ¦ C
---------------------------
¦4 ¦ A
-----------------------------
¦5 ¦ B
---------------------------
¦6 ¦ A
-----------------------------

Now I want to know which record is occurring the most number of times that too in descending order....Is it possible?

scriptmasterdel

2:13 pm on Aug 19, 2007 (gmt 0)

10+ Year Member



SELECT count(Company) as gCount, Company FROM table GROUP BY Company;

The value of gCount will be the count of the occurrences of the distinct name.

I hope this helps.

ayushchd

2:25 pm on Aug 19, 2007 (gmt 0)

10+ Year Member



Thanks A Lot.