1

I have three seperate table without any foregin key or relations each.. database three table

I need a Summary like this should be summary display like this

Now, what and how will be mysql query.. I am very new web developer... please kindly lets me know details. pleas help me on this issues

refference links :: https://stackoverflow.com/questions/6676653/mysql-query-two-tables-get-data-in-date-wise-or-user-wise

0

Here is one approach I've used in the past. I think this will help you with the basics. I've only included 2 of the tables, adding the third should help you to understand the answer rather than copy/paste it.

(You'll need to change the first line to add references to sum(Costings), and add a 'union' 'select ... from bank_mobile_costing', in addition to adding a reference 'Costing' column to the 'Investments' and 'Earnings' select statements.)

select date,sum(Investments),sum(Earnings),sum(Investments+Earnings) as Balance from
(
select date,amount as 'Investments',0.0 as 'Earnings' from bank_mobile_investments
union
select date,0.0,amount from bank_mobile_earnings 


) mydata 
group by date
order by 1

It's worth my noting here that this will NOT display a list of calendar dates in the date column, but rather it displays a complete list of all the dates which exist in your 3 tables; I don't know if that's appropriate to your needs.

On the subject of your running total column at the end, this is a convoluted subject but a quick google search yields the following stack overflow result which gives a couple of methods of doing it, and there are some interesting points raised in the comments about the advantages or drawbacks of the methods.

Calculate a Running Total

  • Thanks for your quick response.. Before posting this problem.. I had try to resolve the problem from dba.stackexchange.com/questions/97773/… (solution of RolandoMySQLDBA) But I did not able to rearrange... It was perfect solution for me.... Can you please refix the Rolando query with my three table. KIndly appreicate – Anwar Hossen Sep 29 '16 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.