subtotalling query data

  • Thread starter Thread starter tjb
  • Start date Start date
T

tjb

I know this is possible but I don't know how to do it.

I have several records that have a matching field (A),
but I want to subtotal everything from a different field
(B).

So for column A there will be several rows with the same
data (aa, bb, cc).

Can I subtotal all of the "aa" records by column B?

I hope this isn't too confusing...Thanks!
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You could do something like this:

SELECT colA, Sum(ColB)
FROM table_name
GROUP BY colA

With data like this:

colA colB
aa 10
aa 15
bb 34
bb 32
cc 40
cc 48

results will be something like this:

colA sum_of_colB
aa 25
bb 66
cc 88

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQVYPyYechKqOuFEgEQLNRACg/f3YsqYsz/VwQBqoYJ6McNHNavMAn0z6
crhiQB7CHs5f0xhJ+zePY4TN
=U0zy
-----END PGP SIGNATURE-----
 
Back
Top