Jump to content

Grouping By SUM from two Table and Subtracting Them Prob


razin223

Recommended Posts

Table  - SELL

------------------------------

|  model  |  quantity |

----------------------------

|  C            |    500    |

|  B          |    500    |

|  C            |  300    |

|  B          |  200    |

-----------------------------

 

 

Table - BUY

 

------------------------------

|  model  | quantity  |

-------------------------------

|  A          |    2000  |

|  B          |    2000  |

|  C          |    2000  |

|  A          |    1000  |

-------------------------------

 

I need to SUM of SELL  and BUY both Group By.

Then I need to subtract them as (BUY - SELL) so I can have the

current status of my stock. Just like this

 

----------------------------

|  model  | quantity  |

-------------------------------

|  A          |    3000    |

|  B          |    1300    |

|  C          |    1200    |

---------------------------------

 

Now how can I do it?My Mysql version is 5.1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.