Need to find only 12th Month or nothing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok. Here is a query that I am working with:

SELECT X.id, Y.year
FROM program AS X LEFT JOIN financial AS Y
ON X.fin_no = Y.fin_no

So basically I am looking up an id in X. Matching the fin_no in A to the
fin_no in Y. And printing out the corresponding years that each id was
active. Now I use the left join because not all ids are represented in Y and
I would just like a blank in the year column if this is true. Now the
financial table is set up like this:

stuff | MONTH | YEAR | stuff
1 2001
2 2001
3 2001
4 2001
etc.

I only want the data for the year from the row were MONTH = 12. When I do
the WHERE Y.MONTH = "12" then it blocks out all of the ids that had no
financial data because there was no month field to match the "12" to. So how
can I narrow my results down to the 12th month and still have the ids with no
financial data displayed with just a null value were the year would be. Im
sorry if this is confusing

Mark
 
Dear Mark:

SELECT X.id, Y.year
FROM program AS X
LEFT JOIN financial AS Y
ON X.fin_no = Y.fin_no
WHERE Y.MONTH = 12
OR Y.MONTH IS NULL

The value of all columns in Y is NULL when there is no row found in the
JOIN.

Tom Ellison
 
What field has the 'month' information? Pull that field like --
Action Month: Month([YourField])

Then use 12 as criteria.
 

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

Back
Top