Dividends for stock report

S

SDMFG

I have two tables, one with a list of all of the stocks in an account. The
second table has dividends paid by stocks. I am trying to return a report
which will the list ALL of the stocks in an account in one column and in
another column list any dividends, if there were any. The problem is that
when I make the query, it returns only stocks that paid dividends. Basically
it would look like this:

NAME DIV
Stock A
Stock B 3.5
Stock C 2
Stock D

Instead, I am getting just:

NAME DIV
Stock B 3.5
Stock C 2
 
B

BobT

Just change the join on your tables. By default it will be an equal join
(show me all records where there's a match). Make it a left join (#2 option
- show all records in your Account table and only those records from your
Dividends table where the joined fields are equal - the arrow will point to
the Dividends table). The SQL will look something like:

SELECT Table1.StockName, Table2.Dividend
FROM Table1 LEFT JOIN Table2 ON Table1.StockName = Table2.Stockname;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top