I am just a 65 year old dabbler who programs as a side hobby to keep me busy and out of trouble so please don't get mad if my question is too simple.
I have developed a MYsql db using visual basic to track my stock transactions. Table tx members shown at bottom.
I have one option to list the latest transactions which does the following:
select * from tx order by tstamp desc;
I then list each row in a grid. What I would like to do, is include the total of the dividends received for each stock listed. The only way that I have figured out how to do that is to fill out the grid, and then execute the following for each row:
select sum(dividend) from tx where ticker = 'TICKER_SYMBOL';
This seems very time consuming. I feel as if there is probably a way to accomplish the same thing with a single query but I just don't see the way forward.
Thanks For any help.
Table tx looks like:
tx_type: buy sell dividend
tstamp: date and time (2021-11-30 16:59:50 for example)