MySQL Forums
Forum List  »  Newbie

Doing calculations in linked tables.
Posted by: Ragnar Brynjulfsson
Date: January 25, 2008 10:48AM

Hi,

I have two tables, one with assets and one with tasks. Each asset can have n number of tasks assigned to it and each task has a status number/percent. What I want to do is to create a view that contains the average status of all tasks assigned to an asset, and join that with the asset list.

Maybe this exlpains it better. Here are the tables I have, and the resulting view.

Asset table:
 id      name
  1      asset1
  2      asset2

Task table:
 id    name    status   linked_asset_id
  1    task1     20       1
  2    task2     30       1
  3    task       5       2

Resulting view (joining the asset and view should be)
 id    name   status
  1    asset1   25
  2    asset2    5

Hope this makes at least some sense.

How would I go about this in MySql?

Cheers,

Ragnar

Options: ReplyQuote


Subject
Written By
Posted
Doing calculations in linked tables.
January 25, 2008 10:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.