Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dumb question

Status
Not open for further replies.

flaviooooo

Programmer
Feb 24, 2003
496
FR
Hey, this is probably a stupid question, but here it goes anyway:

I have following figures:

A B
0 10
2 12
4 11

Now I need to count the times a value bigger than 0 appears in column A and make a sum of all data in B

So I should get
A -2
B - 33

How can I achieve this? Do I need subreports etc or can I do it in the report?
 
Hi,

Try

Select Count(A), Sum(b)
From table
Where a > 0
---
You may need to group by if you have anything else in the table or need to select something.

John


John Barnett
 
Summing field B is easy. Add a text box to your report footer and set its control source to:
Code:
=Sum([B])
To count the instances of field A:
Add an invisible text box to your detail section. Set its control source to:
Code:
=IIf([A]>0, 1, 0)
and set the Running Sum property to Over All.
Add a text box to your report footer to display the count. Set its control source to the name of the invisible text box you just added.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top