Results 1 to 2 of 2
  1. #1
    springboardjg is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Milton Keynes
    Posts
    10

    SQL - Inner Join

    Hi All



    I have a table, a snapshot of which is below.

    Code:
     Site_Serial | HSI_Year | HSI_Month | Weekly_Average
    HLDN0056003 | 2011 | 4 | 254177
    HLDN0056003 | 2011 | 3 | 193223
    KLWT0347001 | 2011 | 4 | 64728
    KLWT0347001 | 2011 | 3 | [NULL]
    LSPA0262001 | 2011 | 4 | [NULL]
    LSPA0262001 | 2011 | 3 | 46921
    I want to return a list of all site serials for the current month that has a weekly average value, so WHERE HSI_Year = 2011 AND HSI_Month = 4 AND Weekly_Average IS NOT NULL

    However, I only want to return a site serial for the current month where the weekly average field IS NOT NULL for both the current month and the previous month. So from the above table I would only want to return...

    Code:
     Site_Serial | HSI_Year | HSI_Month | Weekly_Average
    HLDN0056003 | 2011 | 4 | 254177
    ... because the other site serials either have a [NULL] weekly average for the current month or the previous month.

    Someone has suggested that I use an Inner Join to return the rows that I want. If this is the correct way to go about it could someone give me some pointers with the structure of the SQL query.


    Thanks

    James

  2. #2
    Rixxe is offline Blessed Bear
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Location
    London (Essex ... yep!)
    Posts
    184
    I think this might be useful for you:
    http://en.wikipedia.org/wiki/Join_(SQL)

    Scroll down and look at 'Self Join', it would be worth reading and getting an idea on most of the joins used.
    The examples also give you an idea of the structure that you should be using. If you get stuck come back with what you have.

    Good Luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Join Query?
    By KWarzala in forum Forms
    Replies: 5
    Last Post: 07-29-2014, 02:44 PM
  2. Help with right join
    By usa_dreamer2002 in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 04:47 PM
  3. WHERE as part of JOIN not after
    By thestappa in forum Queries
    Replies: 1
    Last Post: 05-14-2010, 10:52 AM
  4. inner join in query
    By Hrcko in forum Access
    Replies: 1
    Last Post: 02-01-2010, 05:54 PM
  5. SQL JOIN statement
    By seen in forum Access
    Replies: 10
    Last Post: 01-15-2010, 05:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums