• Hi,

    as far as I can tell, LEFT is unnecessary here - in fact, the query performs as with INNER JOIN, because there is condition in the WHERE clause that works with the joined table. Therefore, I would suggest using inner join to make it visible on first glance.

    Something like this should work:

    SELECT s.StoreName, s.StoreID, h.StoreDate, h.OpenTime, h.ClosingTime, h.Comments

    FROM stores s

    JOIN tblhours h ON s.[StoreID] = h.[StoreID]

    WHERE h.[StoreDate] >= DATEADD(d,-7,GETDATE())

    AND h.[StoreDate] <= GETDATE()

    AND s.StoreName = 'store'

    The conditions in WHERE clause depend on what precisely is meant by maximum 7 days (i.e. included today-7 or not?), whether StoreDate has always time-part 00:00:00 or not etc. Since you posted data with no time, I didn't bother with it - it may require some changes before the query works as you expect.

    I mostly avoid BETWEEN when working with time data, because often the right solution includes just one of the limits - not both. For example, if your dates include time, and you want to show data from one month, it is best to do it as >= (first day of month) AND < (first day of next month).

    If you have any problems reaching the result you need, post back with more info about it.