José Carlos Santos wrote:Have you ever heard of aggregate functions?> Hi all:

>

> Imagine that I have a table like this one:

>

> ---------

> | a | 2 |

> ---------

> | b | 3 |

> ---------

> | a | 5 |

> ---------

> | c | 1 |

> ---------

> | c | 3 |

> ---------

> | a | 2 |

> ---------

>

> The firts column has alphanumeric character and the second one

> only has numbers. Let's call it test1. I want to create a table with the

> same structure as the previous one which looks like this:

>

> ---------

> | a | 9 |

> ---------

> | b | 3 |

> ---------

> | c | 4 |

> ---------

>

> Let's call test2 to this table. The idea is this that:

>

> 1) The first column of test2 has the same "objects" in it as test1, but

> each one appears only once.

>

> 2) For each "object", the number on the second column of test2 is the

> sum of all numbers of the second column of test1 which have that

> "object" in the first column.

>

> Is it possible to do this within MySQL? I'm not talking about creating

> the table, only about filling it up.

>

> Best regards,

>

> Jose Carlos Santos

[url]http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html[/url]

Would this query meet your needs?

select first_column, sum(second_column)

from table_name

group by first_column

It's standard SQL.

ciao

gmax

--

_ _ _ _

(_|| | |(_|>< The Data Charmer

_|

[url]http://datacharmer.org/[/url]

## Bookmarks