Query

  • Ok, here's a replacement question...

    Q. What query would return the employees whose 'join_date' (from the employee table)

    was in a month that has 28 days in it? (assume 'join_date' is non-null)

    Are you ready?

    A. select * from employee

    Ok, how many of you started...'take the join_date, go to the first day of the next month, subtract a day....' 😛

    (Hint: All months have 28 days in them)

    Just having fun on Monday morning...:D

    If it was easy, everybody would be doing it!;)

  • OK, guys.

    The way I reckon this'll work is that soon, Steve'll come here, read Pablo's post about dob not being a field in the table being queried, will realise there was a mistake and will adjust points accordingly (as he has done several times before).

    So Pablo's raised the important concern.

    That was reply #1.

    Apart from a couple of interesting syntactical comments (binary collation, missing comma) and a comment on coding best practice guidelines, have any of the other 3 pages of posts added anything new to what Pablo was saying? If not, then why post reiterations?

    Semper in excretia, suus solum profundum variat

  • And so it continues.... 😉

    Tell us another joke major. 😀

    --Shaun

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • Jignesh Mehta (4/6/2008)


    ...

    The other answer " datename(m,join_date) like '%a%' " is also not correct as it will not give the list of employees who joined in the month of FEB

    ...

    datename will print entire month name and February has an "A". however, had the first option been month(join_date) rather than month(dob) it would have been correct, but it was not. Two poor QOD's in a row.

  • Again with the sloppy question and answer????

    The "dob" field is the wrong field. Might exist in this hypothetical database, but it'll give the wrong rows.

    Also, I'd argue that having a query with a function on one side of the Where and "like '%a%'" on the other is an inherently bad answer anyway. Might get the right result, but talk about poorly written code!

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • People, don't worry about the points for it. You get just as many points (1) for joining the discussion to complain about the answer, as you would for getting it right (1). The "points" aren't the point. 🙂

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Doh! datename - look up the function dude!

    takes the raw data and uses the full string of the name so when your field has a datetime type

    datename(m, datetime_field) gives the full English spelling of the month not a three letter version.

    I really cannot believe how many people have jumped to this conclusion that records from February won't be returned. I expected zero but got 1+. 😉

    scary!

    dob was obviously a typo, sloppy!

    --Shaun

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • Simply gonna echo what came before. The dob cannot be right. Want my point.

  • Post multiple times = multiple points :w00t:

    (damn you brain - stop giving away the secrets)

    --Shaun

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • Since the entire table, with all of the column names AND an explanation of each column, was not provided, the column named "dob" does not exist! Even if there was a column labeled "dob", one cannot presume its contents without having a description. Therefore, that choice is clearly wrong. The pattern (LIKE clause) matching is dependent upon character set, language, etc. so it is not accurate.

    Therefore, the only correct answer is "NOT IN LIST".

    This sort of bad Question of the Day means that I'm not going to even waste my time looking at them in the future.


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]

  • Shaun McGuile (4/7/2008)


    Doh! datename - look up the function dude!

    takes the raw data and uses the full string of the name so when your field has a datetime type

    datename(m, datetime_field) gives the full English spelling of the month not a three letter version.

    I really cannot believe how many people have jumped to this conclusion that records from February won't be returned. I expected zero but got 1+. 😉

    scary!

    dob was obviously a typo, sloppy!

    --Shaun

    Um, are you sure, Shaun?

    From what it says in http://msdn2.microsoft.com/en-us/library/ms191307.aspx, the implication is that it'll return a string based on the prevailing language settings. Mind you, I haven't tested it myself.

    Semper in excretia, suus solum profundum variat

  • Sorry major - I meant full (insert local language here) spelling of the month, not an abreviation such as FEB; my bad!

    Thanks for pointing that out. 🙂

    How many pages will this one run for? 😀

    --Shaun

    Hiding under a desk from SSIS Implemenation Work :crazy:

  • arvindravish (4/6/2008)


    I am pretty upset about the fact that the questions posted doesn't seem to be appropraitely matching with the options specified in the list of answers.

    I don't seem to understand what is dob column in the answer option.:hehe:

    I agree - dob is not even a field mentioned in the question. Unless of course employees join the company at birth. 🙂

    -webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Where the field dob specified in the conditions? Now if join_date was in side month(join_date) In Then that would be a correct ans.

  • I just have a couple of questions for all who have posted about this issue, did you respond to the QOD survey that was released recently? Also have you ever submitted a QOD? I agree that the first option is not a correct answer based on the question, but what are you and I doing to improve things?

Viewing 15 posts - 31 through 45 (of 95 total)

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