php - access query from different table with sum, group byGet the solution ↓↓↓
I have the following columns and data on two tables named "tbl_stock" and "tbl_sale"
This should give you what you are looking for.
select distinct stock_yard_name, stock, sale from ( select stock_yard_name , sum(stock_net_weight) stock from table1 group by stock_yard_name) t1 join ( select sale_yard_name, sum( sale_net_weight) sale from table2 group by sale_yard_name ) t2 on stock_yard_name = sale_yard_name
select ref.stock_yard_name,ref.stock_net_weight as stock, ref.sale_net_weight as sale, ref.stock_net_weight - ref.sale_net_weight as advance from( select st.stock_yard_name as stock_yard_name, sum(st.stock_net_weight) stock_net_weight, sa.sale_net_weight from tbl_stock st inner join ( select sale_yard_name, sum(sale_net_weight) sale_net_weight from tbl_sale group by sale_yard_name ) sa on (st.stock_yard_name = sa.sale_yard_name) group by st.stock_yard_name,sa.sale_net_weight )ref order by ref.stock_yard_name asc
Share solution ↓
Link To Answer People are also looking for solutions of the problem: installation failed, reverting ./composer.json and ./composer.lock to their original content
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
About the technologies asked in this question
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.