What is The Query Statment Can do that Logic

  • if i'm Hotel Owner

    and I have 3 Categories on it Normal,High,Kings Rooms

    so i will have that Records

    ID, StartDate, EndDate, RoomName,IsAvaliable

    1 , 2-1-2011, 2-10-2011, Normal Room, True

    2 , 2-11-2011,2-20-2011,Normal Room, False

    3, 2-21-2011,2-28-2011,Normal Room, True

    4, 2-1-2011, 2-28-2011,High Room, False

    5, 2-1-2011, 2-15-2011,Kings Room, True

    6, 2-16-2011, 2-28-2011,Kings Room, False

    I think That Example is more Clear and That is what Exactly what i want

    I want The Days Between 2-10-2011 and 2-18-2011 which all rooms in my Hotel will be Unavalible

    so The Result What i want is it will be

    2-16-2011

    2-17-2011

    2-18-2011

  • ahmedhussein787 (2/16/2011)


    I Have ProductsDates table in

    (ID, ProductionDate,ExpiredDate,IsAvaliable,Product)

    1 , 2-1-2011 , 2-15-2011, false, Milk

    2 , 2-4-2011 , 2-8-2011,true,Cheese

    3 , 2-3-2011 , 2-5-2011,true,Coffee

    4 , 2-7-2011 , 2-13-2011,false, Tea

    5 , 2-9-2011 , 2-15-2011,false, Sugar

    I want to select The Dates that All Products are not Avaliable not During s Dates i Select it like

    from 2-8-2011 to 2-15-2011

    The Result is :

    2- 9-2011

    2-10-2011

    2-11-2011

    2-12-2011

    2-13-2011

    So what is The Select Statment can do that ... i want to avoid looping but if there is no way rather than looping so its ok

    I'm not sure I completely understand the request.

    Do you want to return all of the dates in a range for which the following is true:

    1. Not all Products are Available

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • How do you come to this conclusion?

    Examples:

    Product 2 is available until 2-8-2011. How do you know it's not available after that?

    Product 5 is not available starting from 2-9-2011. How do you know it's available before then?

    Why isn't 2-15-2011 on that list?

    Taking the logic questions aside: What have you tried so far?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • I Want Something Like Intersection between Records that have IsAvalibale=false... The Result of That Intersection will be Records of dates....

    There is A different Between Production Date and ExpiredDate and IsAvalible .....

    If I'm SuperMarket Owner ... I can have Products is Expired and Is Avaliable In My Market

    I want to The Dates Between Production Date and Expired Date which i will have all Products is UnAvaliable on it

  • I will give another Example .... if i'm Hotel Owner

    and I have 3 Categories on it Normal,High,Kings Rooms

    so i will have that Records

    ID, StartDate, EndDate, RoomName,IsAvaliable

    1 , 2-1-2011, 2-10-2011, Normal Room, True

    2 , 2-11-2011,2-20-2011,Normal Room, False

    3, 2-21-2011,2-28-2011,Normal Room, True

    4, 2-1-2011, 2-28-2011,High Room, False

    5, 2-1-2011, 2-15-2011,Kings Room, True

    6, 2-16-2011, 2-28-2011,Kings Room, False

    I think That Example is more Clear and That is what Exactly what i want

    I want The Days Between 2-10-2011 and 2-18-2011 which all rooms in my Hotel will be Unavalible

    so The Result What i want is it will be

    2-16-2011

    2-17-2011

    2-18-2011

  • LutzM (2/16/2011)


    How do you come to this conclusion?

    Examples:

    Product 2 is available until 2-8-2011. How do you know it's not available after that?

    Product 5 is not available starting from 2-9-2011. How do you know it's available before then?

    Why isn't 2-15-2011 on that list?

    Taking the logic questions aside: What have you tried so far?

    The questions still remain unanswered...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Let The First Example I think it was not clear enough but the last is Very Clear to my Idea ... The Last Question for You that Because as i told in the second Reply I want Intersect between all unavalibale Products ... So The Tea will be Expired in 13-2-2011 so i did'nt get any day after that

    ............................................................

    Let The First Example ... The Second is more Clear and That Is What I want

Viewing 7 posts - 1 through 6 (of 6 total)

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