MYSQL query for selecting the result of a condition of one table and showing it on another table -


how substract(or add) 1 row previous row of 1 table(stock_details).. , showing result in table(item_details)..??

 1st table:stock_details ----------+----------+-----------  stock_name | quantity | type   ------------+----------+----------  laddu      |   200    | purchase            ghee      |    50    |  issue           2nd table:item_details ----------+---------- stock_name | quantity    ------------+--------- 

-- insert item_details --  or -- create table item_details select   stock_name, sum(case type            when 'purchase' +quantity            when 'issue'    -quantity          end) quantity     stock_details group stock_name 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -