Count function

SteveWright

New Member
Joined
Aug 26, 2009
Messages
44
Hi guys,

Ive tried to find a solution to this on here with no avail, hopefully one if you can help.

I need to have a field in my query that counts the occurences of ID. i.e.

ID : Count
1 : 2
1 : 2
2 : 1

Any help with the snytax will be much appreciated.

Thanks.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Code:
select 
  id, 
  count(*) as number_of_times_id_occurs
from 
  your_table
group by 
  id
open the query builder, select view sql, paste the above in with your name changes

of course that will only list each id once
after looking at your post again, I don't think that's what you want
 
Last edited:
Upvote 0
If you link the results of the SQL query above on your id field, you can obtain the results you're after.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top