in reply to Perl/MySQL ?

You need something like

SELECT category, SUM(fee) FROM tblproducts WHERE category like 'Phorno +';
That should be it. Since SUM is a grouping func, you need to apply all grouping rules to the selects you plan. Hence be sure the SUM set returns an unique index (for example the CATEGORY here, for which is made a subset).
Without the WHERE, I'd have as much rows in the resulting recordset as there are CATEGORIES in the table.

Hope I made myself clear. :)

Replies are listed 'Best First'.
Re: Simple query
by rdfield (Priest) on Jul 07, 2002 at 10:43 UTC
    Your SQL is incorrect since there is no "group by" expression used in conjuction with the aggregate function:
    SELECT category, SUM(fee) FROM tblproducts /* optional where clause */ GROUP BY category
    would be correct.

    rdfield