Creating view - Join on date

  • I am new to views and have create some straight forward ones.  I have a set of files I am tying to include in a join.  The access to the view will have a specific date, as the program output is date related.  One file I am trying to join does not contain a days date, but the weekending date.  So when it select this view, there is a 'where date =' clause. The join needs to connect this first table to a second table which has on a weekending date.

    The application was set up to have the users put in a forcast for the week, and the report is run daily.  So each day, this join needs to find the week end record in the forcast table.  Can this be done in a join?

    Select t1.SpecCode,t1.info from dailytable t1

    left outer join forcastTable t2 on (t1.date is in [t2.date,t2.date-7]) (I know this isn't valid code)

    or is there another way to attack this issue?

  • Have you tried writing BETWEEN instead of IS IN? And replacing the comma with "AND"?

    left join forcastTable AS t2 on t1.date between t2.date - 7 AND t2.date

     


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply