sum_query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have the following columns in a tabel

A B
IBM x
IBM x
IBM x
SUN x
SUN x
SUN x
MAC x

Need to create a query that summarize column A by counting the nr rows.

A B
IBM 3
SUN 3
Mac 1

Regards,
 
SELECT A, Count(B) as CountB
FROM YourTable
GROUP BY A

In the query grid
-- Open New query
-- Select your table
-- Select your fields
-- Select View: Totals from the menu
-- Change GROUP BY to Count under the field you want to count.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Hi John,

What I want to get back, is a "countif" type result in the query that looks
field A and count it in field B.

Regards
 
I'm sorry, I really don't understand what you want.

Do you want to count column [A].

SELECT [A], Count([A]) as CountA
FROM YourTable
GROUP BY [A]

Do you want to count column B if it has a certain value for each unique
value of A? So only count B if it is equal to "zz"?

SELECT [A], Count(IIF( = "zz",1, Null) as [Count zz In B]
FROM YourTable
GROUP BY [A]



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top