Hi, I would like to use one query to compare aggregate values from columns in two separate tables. I am running mysql 3.23.55 (max). Here is a simplified table structure:
job - job_id - name quote - quote_id - job_id - quote_amount actual - actual_id - job_id - actual_amount I'm trying to figure out the difference between the actual value and the quoted value. The actual and quote tables may have 0->infinity records. To find the difference for only one job, I could write two queries like this: SELECT sum(quote_amount) AS quote_amount FROM quote GROUP BY job_id WHERE job_id = 1 SELECT sum(actual_amount) AS actual_amount FROM quote GROUP BY job_id WHERE job_id = 1 And then find the difference: quote_amount - actual_amount But I'd like to do this for, say, 100 jobs at a time. Can anyone at least point me in the right direction? Should I be looking at temporary tables? Should I think about my table structure? Thanks!! Beau -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]