Query does not show correct result

But the query does not show date 2016-07-18.

Here is query for mysql

SELECT c1.date, SUM(IFNULL(cx.purchase - cx.sold, 0)) + MAX(p.openqty) AS opening, c1.purchase, c1.sold,SUM(IFNULL(cx.purchase - cx.sold, 0)) + MAX(p.openqty) + c1.purchase - c1.sold AS closing FROM ( SELECT open_qt ASopenqty FROM mixed ) p LEFT JOIN ( SELECT a.date, a.qty AS purchase, b.qty AS sold FROM arrival a, pouring b WHEREa.date = b.date ORDER BY a.date ) c1 ON c1.purchase + p.openqty > 0 LEFT JOIN ( SELECT a.date, a.qty AS purchase, b.qtyAS sold FROM arrival a, pouring b WHERE a.date = b.date ORDER BY a.date ) cx ON c1.date > cx.date GROUP BY c1.date,c1.purchase, c1.sold

@tqmd1: please post your code here, rather than just an image of it, which is hard to read. Thank you.

Is there any reason why this is posted in the JavaScript forum, given that you seem to have posted only phpMyAdmin screenshots?

Off Topic

That would be because I hadn’t had enough coffee when I first looked at it and misread the title as jQuery. So after “helpfully” moving it to JS, I’ve now moved it back to PHP.

2 Likes

It might be worth clarifying whether you need help with getting the results you want from the database, or whether you want help in getting those results presented in a web page - one is a database question, the other ‘may’ be a PHP question, but it’s currently difficult to tell.

1 Like

What does it show? You’ve showed us what you want, but what do you get?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.