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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.