Comment On You Get What You Ask For

Nothing screams “easy money” like headhunting. Twenty-five to thirty percent of your recruit’s first annual salary? Twenty dollars off the top of each hour worked by your contractor? With that kind of bling, who wouldn’tsign up as a headhunter? [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: You Get What You Ask For

2007-07-30 15:08 • by Awesome Interviewer (unregistered)
If I could comment first I would locate the comments form and enter some text. I would consult with google concerning the need for captchas. Then I would probably fill that out with "cognac" and press the submit button after locating it.

Re: You Get What You Ask For

2007-07-30 15:09 • by Anonymoose (unregistered)
Seriously, you posted a word document? That's a pretty big WTF right there.

Re: You Get What You Ask For

2007-07-30 15:14 • by TheRubyWarlock
The REAL WTF is that some idiot actually believes in using technical "tests" to weed out candidates. The correct answer IS to look it up.

Re: You Get What You Ask For

2007-07-30 15:16 • by dmitriy
I read the second question in the Word document, and my guess is that the answer involves subqueries and joins. I'm not sure a single query is the best way to approach the problem, though.

Re: You Get What You Ask For

2007-07-30 15:18 • by rycamor (unregistered)
This is the best laugh I have had all week.

Note: Based on my understanding, the purpose of these low-level programming questions is to draw out the participant’s knowledge and usage of reference materials and web knowledge-base searches to derive the answers, demonstrating his approach and thought process. My role as IT Architect for the past 8.5+ years has been to focus on the bigger picture and higher-level architect and design issues that solve specific business problems, so I don’t know the answers to these specific programming questions off-hand (and don’t want to give the impression that I do by going through the actual exercise of copying something off the web, which is done easily enough).

What does our IT Architect consider low-level? Representing a tree in a SQL database, joining two tables in a query, and working with elements in a set. Gotta love it.

Re: You Get What You Ask For

2007-07-30 15:20 • by Anonym (unregistered)
I cant remember if i ever replied here but i'd like to express my opinion on the general lack of quality of thedailywtf.

a) Grammar - sorry im not a native english speaker but i believe Alex is - there are so many spelling errors and mistakes even i could make out in this article.

b) Word Document - nothing to add here - this is just being lazy

c) The third entry about Lee Burch’s candidate. Seriously compare what is written in the word document with the excerpt given in the article. You make the guy look bad for no reason - he acknowledges that he is not a programmer but IT Architect (which i would translate in Project Manager) and to his best knowledge he also said that he could simply copy & paste answers to these simply question by using google (which is easy) but prefered to do not. He even explained why he gave links to possible solutions.
Furthermore judging by the test questions at Lee Burchs company i really got to say that they are looking for a 1 or 2 season IT programming student. If i would judge candidates by these test (i.e. they passed it) i still wouldnt know if they are any good.

Re: You Get What You Ask For

2007-07-30 15:21 • by Srdjan (unregistered)
I don't see what is so wrong with the responses for number 3, unless the applicant is applying for a position that is lower than IT Architect. If so, then he is an idiot. However, if he's applying for an IT Architect or better position, then the recruiter/HR person is an idiot for sending him those questions. Like the applicant and a poster here said, the answer is "Look it up".

Re: You Get What You Ask For

2007-07-30 15:21 • by FredSaw
At least he's only going to have to write one complicatedstoredprocedure.

Re: You Get What You Ask For

2007-07-30 15:29 • by BillWaite
I agree that when you don't know how to do something, looking it up is the right thing to do. The problem is that the guy was too lazy to actually look it up and solve the problems. The interviewer only wanted him to solve 3 problems, which shouldn't be a big deal, but he decided instead to spend 5 minutes writing what basically boiled down to, "I bet I could solve those problems if I really wanted to put in the effort. But I don't, so I'll just tell you that I could probably solve them."

Re: You Get What You Ask For

2007-07-30 15:33 • by Patrick (unregistered)
Of course, besides hitting Google, I would consult with my developers/DBA, colleagues, and internal knowledge databases to see if there’s a more specific best-practice solution.


Stands on the shoulders of his peers...check! Give that man the Senior Architect position!

Re: You Get What You Ask For

2007-07-30 15:36 • by dubbreak
147381 in reply to 147378
BillWaite:
I agree that when you don't know how to do something, looking it up is the right thing to do. The problem is that the guy was too lazy to actually look it up and solve the problems. The interviewer only wanted him to solve 3 problems, which shouldn't be a big deal, but he decided instead to spend 5 minutes writing what basically boiled down to, "I bet I could solve those problems if I really wanted to put in the effort. But I don't, so I'll just tell you that I could probably solve them."


Reminds me of a commercial I saw recently..
interviewer: "There are 10 people that really want this job. What are you willing to do to get it?"

interviewee: "..." (picks up resume, covers mouth while he yawns then shrugs)

Re: You Get What You Ask For

2007-07-30 15:38 • by Ryan (unregistered)
The correct answer IS to look it up.


If you have to look up how to do an SQL join, then you have no business coding anything.

Re: You Get What You Ask For

2007-07-30 15:39 • by ThePants999
I'm not impressed with this "worst response he's ever seen". The article did not summarize the document at all well, and although the architect in question probably should have known more than he did, I thought it was a good response from someone in his position.

Re: You Get What You Ask For

2007-07-30 15:45 • by BillWaite
147385 in reply to 147382
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table. Alex's question summaries/titles are blatantly retarded (though I still maintain that the guy is too lazy to be a good candidate).

Re: You Get What You Ask For

2007-07-30 15:50 • by Crabs (unregistered)
147386 in reply to 147382
I had to look up how to do an SQL join. Some of us don't use databases on a daily basis.

This is not to say that it's not ridiculously easy. But there's no shame in looking something up.

Hell, I've looked up "hello world", just so I could figure out what the hell I was doing in a new language.

Re: You Get What You Ask For

2007-07-30 15:53 • by wikipantia (unregistered)
147387 in reply to 147371
Anonym:

b) Word Document - nothing to add here - this is just being lazy


At least the original author stripped the metadata, leaving only Alex's information from the last save. Could be worse.

Re: You Get What You Ask For

2007-07-30 15:55 • by snoofle (unregistered)
147388 in reply to 147383
I gotta say, if someone gave me questions like that, and they were irrelevant to the job for which I was applying, I'd assume they were idiots and walk out. If they were relevant, but I still couldn't answer them, I'd make a mental note to bone up on those skills, and politely end the interview so as not to waste my/their time. If the questions were sensible and relevant, I'd wonder why the other person needed to ask them, and their response would determine if I let the interview proceed further.

As far as the response given by this candidate that he'd look it up, I think I would have shortened it to:

"I'd get one of my developers to do it; I am (applying for a position as) a manager/Architect!"

Re: You Get What You Ask For

2007-07-30 15:56 • by anon (unregistered)
147389 in reply to 147382
Ryan:
The correct answer IS to look it up.


If you have to look up how to do an SQL join, then you have no business coding anything.


And if you have to look up any of these things, you have no business being an architect in an environment using Relational DBs and OO programming. Saying those things are beneath an architect is like saying knowing how to add is beneath a chip designer- he might not do it everyday, but he can do it.
Maybe that guy could be an architect, in a different environment. My guess is no.

Re: You Get What You Ask For

2007-07-30 15:56 • by Davis (unregistered)
Can whoever takes these screen shots, please turn off their damn ClearType (a.k.a. MSFuzzyType) settings!

Damn thats a hard image to read! Just what I need to see when trying to read black text on a white background.. a bunch of rainbow-looks-like-an-anti-aliased-jpeg garbage image.

I love the daily WTF, but that image is horrible, where are those damn goggles...

Re: You Get What You Ask For

2007-07-30 15:57 • by snoofle (unregistered)
147391 in reply to 147385
BillWaite:
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table....

For the non-db developers among us, how might one do that?

Re: You Get What You Ask For

2007-07-30 16:04 • by BillWaite
147393 in reply to 147391
snoofle:
BillWaite:
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table....

For the non-db developers among us, how might one do that?


The sample output shows they only want Course Number and Instructor, both of which are columns in the Instructors table. No information from the Courses table is needed. But as for how to do it, I don't know; I would have to look it up.

Re: You Get What You Ask For

2007-07-30 16:05 • by Sharkie (unregistered)
With the general quality of coders in the employment pool, I'd be absolutely thrilled to find one that would actually perform web searches to locate solutions, as well as work with internal resources towards the best solution.

Re: You Get What You Ask For

2007-07-30 16:05 • by James (unregistered)
Not sure I'd count this guy out so fast. Remember, Laziness is a Virtue. I'm having trouble finding the named 'axiom', but I'm pretty sure Rule #1 is "Never write it if somebody else has done it for you", and Rule #2 is "If you look hard enough, somebody has already done it."

Anyway, without the context of what job he was applying for, we don't know if his answers were a WTF or not. I've applied for jobs before where they ask questions that lay outside the skillset in the advert, so if I didn't know SQL (I'm actually pretty bad at it), and applied to a position for a .NET developer (with no mention of SQL), I imagine my answers would be similar to this guy's if a SQL question came up during the interview. It's slightly more intelligent than "Uh, I'm not really familiar with SQL, so I don't know."

Re: You Get What You Ask For

2007-07-30 16:06 • by nightkhaos (unregistered)
I have seen many occasions where someone has failed an exam or job application just because they did not answer the question that was asked I think it is kinda sad that some people can look at a question and see something completely different to what is written on the page.

2nd grade math test

2007-07-30 16:14 • by jtl (unregistered)
2+2=

Here I would just ask my daddy for the answer, or use my calculator.

Re: You Get What You Ask For

2007-07-30 16:22 • by htg (unregistered)
I think I would have looked at the answers, agreed that the approach was sensible, and then not hire the guy because he actually didn't do it - unless the other candidates were worse. Hey, I asked you some questions, so damn well answer them. I let you do them in your spare time at home because I expect you to use Google anyway.

Hell, I can't write a simple file loader on some days if I haven't done I/O for a while, and need to look up the code online. APIs are massive and tests that are API centred can be quite useless except for specific required knowledge, demonstrate to me that you know what to search for, that you won't reinvent the wheel without good reason, and that you can do it quickly, efficiently and with some decent comments/documentation. Indeed thought process can be a valid form of documenting something when you are explaining why you chose to do something in a particular way.

My view of the role of architect, because that is my job title, is that you do the important stuff as well as the high level stuff. The database schema is extremely important so you want to be involved with that, but the code to interface with it? Well I'd write some code so that the minions can use it as a basis for their code if they haven't done it before. Network code as well, unless you have an experienced minion you can trust. But do I want to code piles of business logic? Nope.

Re: You Get What You Ask For

2007-07-30 16:23 • by JS (unregistered)
Wow, that guy must be some kind of wizard, summoning a fantastic oracle known as "Google" to find his answers.

But seriously, I agree with him that Question 3 doesn't make sense.

Re: You Get What You Ask For

2007-07-30 16:23 • by Strilanc (unregistered)
There's nothing wrong with looking up answers. But he didn't do that, he just said he would look them up. If you're so good at searching, why don't you do a search and give me the answer?

Re: You Get What You Ask For

2007-07-30 16:27 • by snoofle (unregistered)
147405 in reply to 147393
BillWaite:
snoofle:
BillWaite:
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table....

For the non-db developers among us, how might one do that?


The sample output shows they only want Course Number and Instructor, both of which are columns in the Instructors table. No information from the Courses table is needed. But as for how to do it, I don't know; I would have to look it up.

Actually, the attachment shows they wanted course name and instructor, which definitely requires a join.
I'm guessing some sort of case-statement as part of the select-clause is the way to go, but that's waaay out of my experience with sql...

Re: You Get What You Ask For

2007-07-30 16:29 • by Zygo (unregistered)
147407 in reply to 147393
BillWaite:
snoofle:
BillWaite:
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table....

For the non-db developers among us, how might one do that?


The sample output shows they only want Course Number and Instructor, both of which are columns in the Instructors table. No information from the Courses table is needed. But as for how to do it, I don't know; I would have to look it up.



SELECT CourseNo,
CASE WHEN cnt <= 2 THEN i1 ELSE 'Comittee' END AS Instructor1,
CASE WHEN cnt = 2 THEN i2 ELSE NULL END AS Instructor2
FROM (
SELECT CourseNo, MIN(Instructor) AS i1, MAX(Instructor) AS i2, COUNT(*) as cnt
FROM "Course Instructors" GROUP BY CourseNo
) AS q ORDER BY CourseNo;


If there are 43 gazillion instructors teaching a single course, then maybe the COUNT(*) is too slow and should be replaced by a subquery that uses EXISTS and/or whatever extension syntax this particular database uses to implement offsets and limits. But as for how to do it, I don't know; I would have to look it up.

As far as I know, no SQL book I've ever read contains a trivial answer to this specific question (i.e. some kind of mental process approximating "thought" is required). Then again, no SQL book I've ever read has said that I can ever use COUNT in a WHERE clause either. Maybe I'm just reading the wrong SQL books.

Re: You Get What You Ask For

2007-07-30 16:34 • by SomeCoder (unregistered)
147408 in reply to 147407
Zygo:
BillWaite:
snoofle:
BillWaite:
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table....

For the non-db developers among us, how might one do that?


The sample output shows they only want Course Number and Instructor, both of which are columns in the Instructors table. No information from the Courses table is needed. But as for how to do it, I don't know; I would have to look it up.



SELECT CourseNo,
CASE WHEN cnt <= 2 THEN i1 ELSE 'Comittee' END AS Instructor1,
CASE WHEN cnt = 2 THEN i2 ELSE NULL END AS Instructor2
FROM (
SELECT CourseNo, MIN(Instructor) AS i1, MAX(Instructor) AS i2, COUNT(*) as cnt
FROM "Course Instructors" GROUP BY CourseNo
) AS q ORDER BY CourseNo;


If there are 43 gazillion instructors teaching a single course, then maybe the COUNT(*) is too slow and should be replaced by a subquery that uses EXISTS and/or whatever extension syntax this particular database uses to implement offsets and limits. But as for how to do it, I don't know; I would have to look it up.

As far as I know, no SQL book I've ever read contains a trivial answer to this specific question (i.e. some kind of mental process approximating "thought" is required). Then again, no SQL book I've ever read has said that I can ever use COUNT in a WHERE clause either. Maybe I'm just reading the wrong SQL books.



Yeah, that looks about right.

I deal with SQL fairly regularly and I'd have to look something like that up. Granted, I'm no DBA and I don't have to do terribly complicated things but case statements are way beyond "trivial" and wouldn't be something I would expect a regular programmer to know off the top of his head.

A DBA on the other hand... yes, they probably should be able to write that statement in their sleep.

Re: You Get What You Ask For

2007-07-30 16:41 • by shambo
I received that same transit SQL job posting. I even asked a DBA friend of mine if that was something new. :)

Q3 is dumb

2007-07-30 16:42 • by pm (unregistered)
the only operation you can do on a hashset that comes close is the boolean contains test. THis does not locate an object (as the guy points out)

I assume that the question wants you to recreate the original hash code by jiggling around some string and integer values somehow. IS that behaviour 100% portable; do I have to create a custom hashcode overload. Why would I want to do this anyway; its sounds like I acually want a map

I would certainly interview the guy hw was willing to say precisle what he was thinking and showed that he can find things out.

I wouldnt apply for the job having seen this test though

Now if you reallly want to hear of a bad interview / test. I asked a guy to do a coding test in a live interview; he stood up, said ' i dont have thim for this kind of b*llsh*t' and left

Re: You Get What You Ask For

2007-07-30 16:47 • by Strider
147411 in reply to 147405
snoofle:
BillWaite:
snoofle:
BillWaite:
Ryan:
The correct answer IS to look it up.

If you have to look up how to do an SQL join, then you have no business coding anything.


Actually, Question 2 really had nothing at all to do with a SQL join. In fact, though the schema for two tables is shown, you can solve the problem using only ONE table....

For the non-db developers among us, how might one do that?


The sample output shows they only want Course Number and Instructor, both of which are columns in the Instructors table. No information from the Courses table is needed. But as for how to do it, I don't know; I would have to look it up.

Actually, the attachment shows they wanted course name and instructor, which definitely requires a join.
I'm guessing some sort of case-statement as part of the select-clause is the way to go, but that's waaay out of my experience with sql...


"Create a query which will print the all the courses "

so...actually, you only need the instructor table because it just asks for courses, didnt ask for course names, and the sample output is courseNo...

i would probably do something to the effect of

SELECT DISTINCT COURSENO,
IF(SUB1.COUTNO > 2) THEN 'Comittee'
ELSE IF (SUB1.COUNTO < 1) THEN NULL
ELSE SUB2.INSTRUCTOR AS INSTRUCTOR1
END
END
IF (SUB1.COUNTNO == 2) THEN SUB3.INSTRUCTOR AS INSTRUCTOR2
END
FROM
COURSE_INSTRUCTORS INNER JOIN
(SELECT COURSENO, COUNT(*) AS COUNTNO FROM COURSE_INSTRUCTORS GROUP BY COURSENO) AS SUB1
ON COURSE_INSTRUCTORS.COURSENO = SUB1.COURSENO
INNER JOIN
(SELECT * FROM COURSE_INSTRUCTORS LIMIT 1) AS SUB2
ON COURSE_INSTRUCTORS.COURSENO = SUB2.COURSENO
(SELECT * FROM COURSE_INSTRUCTORS LIMIT 1,1) AS SUB3
ON COURSE_INSTRUCTORS.COURSENO = SUB1.COURSENO


Of course, I think I might have just mixed a couple of different SQL languages there, but you get the general idea. the only thing you might have a question about is LIMIT 1, 1 skips the first 1 and gives only 1 more (i.e. the second row)...
Heck, I'd be suprised if this compiles, but...thats what debugging is for.

Re: You Get What You Ask For

2007-07-30 16:49 • by jan (unregistered)
u wannt to say question 2 is as easy a using a join?

ud have to use a rather complicated case construct or multiple subqueries, which sucks. im sure the least of you could solve that task "off hand". i couldnt

Re: You Get What You Ask For

2007-07-30 16:50 • by Shinobu (unregistered)
147413 in reply to 147390
Davis:
Damn thats a hard image to read!
a) You're grossly exaggerating.
b) Turning off ClearType is work and actually makes it look worse on most displays.

Re: You Get What You Ask For

2007-07-30 16:55 • by Jimmy (unregistered)
147416 in reply to 147374
FredSaw:
At least he's only going to have to write one complicatedstoredprocedure.


Watch out! It's one hell of a procedure.

The Stored ÜberProcedure

Re: You Get What You Ask For

2007-07-30 16:56 • by Zygo (unregistered)
Admittedly my Java-Fu is all grasshopperish, but I don't really get question #3 either.

AFAICT there's no method on HashSet named contains that accepts an Object and returns an Object from the HashSet. There are a number of methods inherited from various places with similar names to contains (contains, containsKey, containsValue...) which all return bool, and there's a method named get that does take an Object and return a similar Object from the hash table (using Object's hashCode method, presumably).

If you just want to know if the object is in the HashSet, that should be trivial: just construct an object identical to the one that was inserted, and fire it into contains(). Someone, somewhere, in the implementation must "locate the original Object" in order to determine whether contains() returns true. There's no explicit requirement to do anything else with the object (e.g. return a reference to it), so in theory all the question requires is a check that contains returned true (although it could be written much more clearly).

Why would you want to do this? Why, to see if some new object is identical to any object inserted before. Duh. Any architect knows that...

Re: You Get What You Ask For

2007-07-30 16:57 • by FredSaw
147418 in reply to 147395
James:
Anyway, without the context of what job he was applying for, we don't know if his answers were a WTF or not.
Quoting the test:
"Create a query which will...". Not "How would you create"; just "Create".
"Write a java program that...". Not "How would you write"; just "Write".

The questions were not hypothetical.

Re: You Get What You Ask For

2007-07-30 17:03 • by Jerim
147420 in reply to 147378
I like your explanation. I was starting to wonder if the interviewer was just being extremely demanding. But I can see your point. Given that he was sent the questionnaire and had time to complete it properly, he should have researched the answers. However, I would maintain that if you are sitting in an office, face to face with someone; I don't see where his answers should initially sink his chances.

Re: You Get What You Ask For

2007-07-30 17:05 • by Mario (unregistered)
The answer for Q1 should contain a note about the number of parents. You could assume one parent per child, but it may be more than one. Remember, reader, you have 2 parents!

Re: You Get What You Ask For

2007-07-30 17:09 • by Jerim
147423 in reply to 147418
I am no DB Admin, but it seems that you would have difficulty creating a conditional query. There are three possible combinations, and the query would have to identify which one it is and act accordingly. Not sure if there is a query language that can do IFs. As for the Java program, I don't like it when a person's hands are tied. It wasn't just "write a program" it was "write a program that solves X using method Y." That is too specific, and seems like they wanted a coding monkey that would just type what he is told.

Re: You Get What You Ask For

2007-07-30 17:09 • by Frank (unregistered)
147424 in reply to 147410
@ 2007-07-30 16:42 • by pm

#contains() locates an object in the sense that you know whether or not it's in the set. Useful.

You assume too much. You receive the spec, and if the spec is not specific, you code generically. What if, say, they want a Month class, with a separate instance for different languages? Bad idea, sure, but not inconceivable. And then, a map would be useful. What would be the key? The number of the month is duplicated, the name *may* be. What if more information to be stored is forthcoming?

Besides, this guy missed an incredibly obvious fact: You do not need the original object, you need to recreate an object that *equates* to the original object. In Java, with HashSets, that means overriding the #equals(Object) method and the #hashCode() method. That's elementary Java knowledge, and any Java programmer should know this. Many don't, and it is the purpose of the test to weed those out.

Re: You Get What You Ask For

2007-07-30 17:11 • by cavemanf16
147425 in reply to 147366
TheRubyWarlock:
The REAL WTF is that some idiot actually believes in using technical "tests" to weed out candidates. The correct answer IS to look it up.


And yet, the "test" weeded out an obviously clueless candidate. Hmmm... interesting how that works.

Re: You Get What You Ask For

2007-07-30 17:14 • by zip
Did anyone here actually read that word document? The questions (espcially #3) are <i>horribly</i> written. If this wasn't because of anonymization (and I don't see why this would need to be anonymized) then I'd say the real WTF is him writing 2 pages of BS when he should've told them to shove it as soon as he saw how badly their standard "test" was written.

Re: You Get What You Ask For

2007-07-30 17:17 • by unklegwar
The funny thing (to me) is that the readability of that first entry is on par with the readability of many TDWTF articles.

Spelling? For the weak.
Missing a verb or three? Inconsequential.

Stones. Glass houses. Etc etc etc.

Re: You Get What You Ask For

2007-07-30 17:20 • by Jon W (unregistered)
Yeah, question 3 really doesn't make sense. What they probably meant to say was "...and tests that the original object is in the set, not using the original object as an argument."
In that case, it shows that you know you have to override equals() when you override hashCode() (and vice versa). And that you have to override hashCode() when you want your hash to be data dependent.

Question 2 was NOT trivial -- props to Z for the elegant solution. I totally had to look that up.

Being lazy enough that you don't get down to writing and testing the answers, though, is not a good indication in a presumptive candidate. I would write "I assume that, as an IT architect, I will mostly spend time going to vendor marketing lunches, but to show I'm rooted in the trenches, here are my solutions" or something like that :-)

Re: You Get What You Ask For

2007-07-30 17:20 • by Zygo (unregistered)
147429 in reply to 147411
"Create a query which will print the all the courses"

When reading this I get visions of reams of paper coming out, as the entire course (including all lecture notes, textbooks, answer guides...) comes flying out of one of those high-volume campus-sized laser printers, all because someone wanted "all the courses" printed.

I also notice the question doesn't specify what happens when zero instructors are teaching a course. Inevitably there will be many attempts to implement answers here. It will be interesting to see how many cope with that case.

My first one doesn't--guess I need a left join after all:


SELECT CourseNo,
CASE WHEN cnt <= 2 THEN i1 ELSE 'Comittee' END AS Instructor1,
CASE WHEN cnt = 2 THEN i2 ELSE NULL END AS Instructor2
FROM (
SELECT CourseNo, MIN(Instructor) AS i1, MAX(Instructor) AS i2, COUNT(*) as cnt
FROM "Course Instructors" LEFT JOIN "Courses" USING (CourseNo) GROUP BY CourseNo
) AS q ORDER BY CourseNo;

Re: You Get What You Ask For

2007-07-30 17:22 • by Zygo (unregistered)
147430 in reply to 147421
Mario:
The answer for Q1 should contain a note about the number of parents. You could assume one parent per child, but it may be more than one. Remember, reader, you have 2 parents!


Then it's not a tree any more. A tree where nodes have multiple parents is called a directed acyclic graph (DAG).

Re: You Get What You Ask For

2007-07-30 17:32 • by Zygo (unregistered)
147431 in reply to 147429
Zygo:

FROM "Course Instructors" LEFT JOIN "Courses" USING (CourseNo) GROUP BY CourseNo


I of course meant

FROM "Courses" LEFT JOIN "Course Instructors" USING (CourseNo) GROUP BY CourseNo

although instructors who teach courses that don't exist is yet another interesting case that has no specified outcome in the test question.

The more the text of the question is analyzed, the more it falls apart. One could literally interpret "print the all the courses and if one instructor ... display ... if two instructors ... print ... if more than two instructors ... display ..." according to strict Boolean logic and end up with two printouts and a pile of text on the screen.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment