> -----Original Message-----
> From: Benjamin Pflugmann [mailto:[EMAIL PROTECTED]] 
> Sent: sábado, 25 de enero de 2003 21:38
> To: Jesper Frank Nemholt
> Cc: [EMAIL PROTECTED]
> Subject: Re: How to combine two selects into one ???
> 
[clip]
> If I understand you correcty, the following should do what 
> you want (untested):
> 
>   SELECT   timecode,
>          SUM(IF(username='jfn',cpuusage,0)),
>          SUM(IF(username='root',cpuusage,0))
>   FROM     process
>   WHERE    systemid = 2 AND
>            timecode > now() - INTERVAL 1 DAY AND
>          username in ('jfn', 'root')
>   GROUP BY timecode
>   ORDER BY timecode
> 
> Note that it will be somewhat slower than two seperate 
> queries, I think.

Thanks, it did exactly what I wanted :-)

The other example you listed has the problem that my application, or
rather the PHP script that generates the graphics, only works if the
output is organized as one timecode followed by a number of values for
each row.

/Jesper


---------------------------------------------------------------------
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