I have table items
| iid | iname | quantity | did | price_kg |
| 1 | rice | 40 | d2 | 2 |
| 2 | sugar | 20 | d2 | 16 |
| 3 | dall | 30 | d1 | 20 |
| 3 | dall | 30 | d3 | 20 |
| 3 | dall | 30 | d2 | 20 |
I have another table soldtable
| iid | pid | soldquantity |
+------+------+--------------+...
User Profile
Collapse
-
To multiply two coluumns which are in two different columns
-
Ok sir its working. Thank you for your help. -
...Code:select items.iid, SUM(items.quantity)-sum(soldtable.soldquantity) as remquantity from items inner join soldable on items.iid = soldtable.iid group by iid,pid; My tables are: items: iid iname quantity 1 Rice 40 2 Sugar 20 3 Dall 30 soldtable: iid Pid Soldquantity 1 P1 5 1 P2 6 2 P1 4 2 P2 5 I'm getting the output as: iid Remquantity 1 35 1 34 2 16
Last edited by Rabbit; Mar 19 '15, 06:58 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.Leave a comment:
-
-
To subtract two columns which are in two different tables
I have 2 tables, items and sold . In items table I have itemid , item name , quantity and in sold table I have itemid , peopleid, itemname , soldquantity. I want the output as itemid, itemname,remqua ntity(quantity-soldquantity) and where will the final output will store?
No activity results to display
Show More
Leave a comment: