• cs_source (1/2/2014)


    Hi salamex,

    Thank you, this query is very similar to my first query and it works great if the car is in "service/shop" on the same day, the problem i ran into after doing some validation is that it excludes cars that span more than one day.

    That is because the "between" join doesn't work example:

    same day : 08:00 - 13:00 (8,9,10,11,12,13)

    different day: 21:00 - 03:00 (null)

    i think i'll just need to do 2 queries but still working it out.

    A little sample data would go a long way.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden