is there countif in access !

ahmed kamal

New Member
Joined
Aug 28, 2015
Messages
14
hello guys,
i wonder is there countif in access query like excel !
i have a table that contains names like
NameResult I want
Sarah1
John1
Mick1
Sarah2
Sarah3
John2

<colgroup><col><col></colgroup><tbody>
</tbody>

i need a formula that count like that in result column, is that possible in access
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You will need to build a query. Here is a SQL statement for that query. Assumed your table to be named "tblSample"
Code:
SELECT tblSample.Name, Sum(tblSample.[Result I want]) AS [SumOfResult I want]
FROM tblSample
GROUP BY tblSample.Name;
 
Upvote 0
I tried that code but the result was like that

nameSumOfResult I want
Sarah3
John2
Mick1

<tbody>
</tbody>

but i want query show a result like below, hope you will help me

NameResult I want
Sarah1
John1
Mick1
Sarah2
Sarah3
John2

<tbody>
</tbody>
 
Upvote 0
Looks like you want what is called a running total. You can only do that in MSAccess reports.
 
Upvote 0
Maybe this?

Code:
SELECT tblSample.Name, Count(tblSample.Name) AS CountOfName
FROM tblSample
GROUP BY tblSample.Name;
 
Upvote 0
Code:
SELECT tblSample.Name, Count(tblSample.Name) AS CountOfName
FROM tblSample
GROUP BY tblSample.Name;
That would be the same as Post 3. Except Post 3 should have showed sums, not counts. In other words, it shows a single value (count) for each name, not a running count per row for each name. It is possible to get running sums using the methods posted in the link....but...

the butts:
  • you need to have a key with ordering implied (1,2,3...) in order to find the "last record" or "previous record" in a meaningful way and in fact to make the running sum possible. Also requires some understanding of SQL beyond the basics (whereas it seems that hardly anyone bothers to even learn the basics now).
  • Code solution is great but better for advanced Access users.

If there is no primary key you could create a temporary table with an autonumber id, and use that to create ordering and uniqueness for each row, as a basis for building a query.
 
Upvote 0

Forum statistics

Threads
1,221,657
Messages
6,161,084
Members
451,684
Latest member
smllchng5

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