I am stuck here, I have to display sum of each share of specific share group by symbol I have tried a lot but could not get it how can I display them in the html.This is my index.py code right now, I am using loop to display each symbol separately.
I think I know what you are after. You could try your SQL as something like this:
SELECT stocks, price, SUM(shares) as total_shares, SUM(shares) * price AS total FROM porfolio WHERE user_id = ii GROUP BY stock ORDER BY stock
I tested this so it should work.
I removed you " * " when making the SELECT statement because the 'shares' columns would contradict the new 'total_shares' column.
Let me know if you need clarification on my code.
And then I would display them in html by using the loop? Apr 5, 2017 at 7:27
Made some changes and it is working fine now, Thanks for the help. Apr 5, 2017 at 7:58