I'm having a little trouble working out an alternative way to do a
particular subselect (as would be) in MySQL.  The basic problem is a
situation where I have a table with 3 columns:

id, group, value

I want to get the sum of the minimum x values for each of the groups.
Something along the lines of:

SELECT group, SUM(value) FROM table GROUP BY group;

would get the sum of all values, but I want to have something along the
lines of:

SELECT value FROM table ORDER BY value LIMIT x;

instead of the 'value' in the SUM (I think that would work, it's a while
since I've had an SQL server that copes with subselects, procedures,
etc. to work with!).

Does anyone have any good ideas or am I (as I suspect) going to have to
resort to a bit of Perl and some temporary tables?

Thanks in advance,

-- 
Paul Tansom:  -  contact [EMAIL PROTECTED] for more information
Internet and Intranet Solutions   --   http://www.aptanet.com/

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to