NOT BETWEEN

  • Comments posted to this topic are about the item NOT BETWEEN

  • Nice easy one to end the week ....

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Good question Steve.

    M&M

  • We like these questions that require fewer brain cells to cap the week.

    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

  • Hi..

    I got 1,6 as output..

    I run this query on SQL server and got the same output.

    Please let me know how we can get 2 as output.

  • The question asked how many rows are returned. It didn't ask which rows were returned.

    Dave

  • just wake up from snap. I miss NOT BETWEEN --> BETWEEN so my answer: 4 :hehe:

  • Nice QOTD to end the week.

    Thanks Steve.

  • Thanks Steve for an easy question to finish the week!

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • This one was so easy that I was looking for the "trick." I kept look and looking but never found one so I finally submitted my answer. I was relieved to see that I got it right. The amount of tension waiting to see the "You got it right" message was overwhelming.

  • Thanks for the easy QOTD!

  • Easy point today - thanks Steve

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • cengland0 (3/30/2012)


    This one was so easy that I was looking for the "trick." I kept look and looking but never found one so I finally submitted my answer. I was relieved to see that I got it right. The amount of tension waiting to see the "You got it right" message was overwhelming.

    +1

    I do not like qotd too easy or without tricks.

    :w00t:

  • Carlo Romagnano (3/30/2012)


    cengland0 (3/30/2012)


    This one was so easy that I was looking for the "trick." I kept look and looking but never found one so I finally submitted my answer. I was relieved to see that I got it right. The amount of tension waiting to see the "You got it right" message was overwhelming.

    +1

    I do not like qotd too easy or without tricks.

    :w00t:

    I get paranoid when the question SEEMS too easy. Sometimes life really is that easy - strange but true. 🙂

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • I guessed 2 because BETWEEN is inclusive, and then I tried to run it. I found out that I needed SQL Server 2008 compatibility, don't have that, only 2005, so I changed the VALUES clause to UNIONs, and the DATE to DATEtime, then fuond out I had to be logged in as dbo, don't have that either, so I took the dbo. off of the select, and then it returned two rows, voila`!

    CREATE TABLE SalesDates

    (id INT, saledate DATEtime

    );

    go

    INSERT INTO SalesDates

    SELECT

    1, '2012/1/1'

    UNION

    SELECT

    2, '2012/1/2'

    UNION

    SELECT

    3, '2012/1/3'

    UNION

    SELECT

    4, '2012/1/4'

    UNION

    SELECT

    5, '2012/1/5'

    UNION

    SELECT

    6, '2012/1/6';

    go

    SELECT id

    FROM SalesDates s

    WHERE s.saledate NOT BETWEEN '2012/1/2' AND '2012/1/5';

    go

    DROP TABLE SalesDates;

Viewing 15 posts - 1 through 15 (of 29 total)

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