10 Groups of 100

  • Thread starter Thread starter Adam Turner via AccessMonster.com
  • Start date Start date
A

Adam Turner via AccessMonster.com

I was interviewed for a job today and they asked a question that baffled me.

If you were given a list of 100 names, how would you seperate them into 10
distinct groups?

I asked, "Grouped by what?"
His response, "Just ten groups"
My response, "I would run 10 queries"
His response, "What would the result set look like?"
My response, "10 distinct groups"
His response, "10 distinct groups of what?"
My response, NO KIDDING, "That was my original question"

I asked him to be more specific, but that was a hopeless endeavor.

My best guess is he was looking for the following but a question will follow:

Select TOP 100 Name, Name, Name, Name, Name, Name, Name, Name, Name, Name
From MyTable
Group BY Name, Name, Name, Name, Name, Name, Name, Name, Name, Name

....but how do you get the first set of 10, the second set of 10...etc?

Is this a function of FETCH STATUS CURSOR documentation I'm not aware of?

He didn't give me the answer, and I'm dying to know if there is one.

Thanks to all that reply,

Adam Turner
 
Dear Adam:

As you already know, you can get a set of the first set of 10 rows with TOP
10. To get a second set of 10, take the top 10 of the last 90:

SELECT TOP 10 *
FROM (SELECT TOP 90 *
FROM YourTable
ORDER BY X desc, Y desc, Z desc)
ORDR BY X, Y, Z

Then the top 10 of the bottom 80, 70, 60, . . .

Now as soon as there are not 100 rows you won't be looking for sets of 10,
but of some other size. Use:

SELECT TOP 10 PERCENT *

instead.

So, your interviewer didn't know what he was talking about. In that case,
just dazzle him with the best BS you've got. You don't score points by
making him look stupid. However, if you act like you know what you're
talking about, and let him think you think he knows what he's talking about,
that's probably the best of all possible worlds.

Now, it is about this point that I start asking myself whether I would want
to work for such an employer.

Tom Ellison
 
Adam Turner via AccessMonster.com said:
I was interviewed for a job today and they asked a question that baffled me.

If you were given a list of 100 names, how would you seperate them into 10
distinct groups?

I asked, "Grouped by what?"
His response, "Just ten groups"
My response, "I would run 10 queries"
His response, "What would the result set look like?"
My response, "10 distinct groups"
His response, "10 distinct groups of what?"
My response, NO KIDDING, "That was my original question"

I asked him to be more specific, but that was a hopeless endeavor.

My best guess is he was looking for the following but a question will follow:

Select TOP 100 Name, Name, Name, Name, Name, Name, Name, Name, Name, Name
From MyTable
Group BY Name, Name, Name, Name, Name, Name, Name, Name, Name, Name

...but how do you get the first set of 10, the second set of 10...etc?

Is this a function of FETCH STATUS CURSOR documentation I'm not aware of?

He didn't give me the answer, and I'm dying to know if there is one.

Thanks to all that reply,

Adam Turner

Perhaps it was a question for which he didn't really expect an answer but
rather to assess your reaction to stress or something. Unless you were
supposed to assume that there were groups on names in the list, I don't
think there was sufficient information provided to supply a meaningful
solution. If that's the case, either the interviewer was too dumb to know
it, or he was looking for something else.

What was that exam that Kirk cheated on in the original Star Trek series?
The Kobyashi Maru, or something like that?
 
Adam Turner via AccessMonster.com said:
I was interviewed for a job today and they asked a question that baffled me.

If you were given a list of 100 names, how would you seperate them into 10
distinct groups?

Adam,

This is a hopelessly ridiculous question for an SQL/RDBMS topic.

I asked, "Grouped by what?"
His response, "Just ten groups"

Ooooo . . . . K!

<And many acronyms about falling off my chair and laughing, etc. />

It could be kludged, I'm sure.

You could run a query to generate an artificial ascending number
column next to the names that went 1 for 10 rows, 2 for the next 10
rows, etc., and wrap a grouping query around that.

But it would be the kludge of the day, would be meaningless in
general, and the person who asked it should be fired.

Why didn't they ask you about recursive relationships and their
implementation? Something *meaningful* and *serious*?

My response, "I would run 10 queries"
His response, "What would the result set look like?"

There would be 10 result sets, not one, so this is a non-sensical
question to ask you, invalid, inappropriate, and offers additional
proof that the person who asked it should be fired and then
blackballed from ever laying a hand to code or compilers or
interviews again.

My response, "10 distinct groups"
His response, "10 distinct groups of what?"

.. . . do de do do . . .

We Are Now Entering The Twilight Zone.

My response, NO KIDDING, "That was my original question"

<I've already done the falling off the chair laughing thing . . . />


Sincerely,

Chris O.
 
How about names starting with a,b,..,i and then all others?

select (case when fc='a' or fc='b' or fc='c' or fc='d'
or fc='e' or fc='f' or fc='g' or fc='h'
or fc='i'
then fc
else 'j onwards' end) as firstchr, name
from
(select lower(substring(name from 1 for 1)) as fc, name
from names) as names2
order by firstchr, names;

That's a result set with 10 distinct "groups" of names with a
distinguising column...
 
Randy said:
I was interviewed for a job today and they asked a question that baffled me.
[quoted text clipped - 26 lines]
Adam Turner

Perhaps it was a question for which he didn't really expect an answer but
rather to assess your reaction to stress or something. Unless you were
supposed to assume that there were groups on names in the list, I don't
think there was sufficient information provided to supply a meaningful
solution. If that's the case, either the interviewer was too dumb to know
it, or he was looking for something else.

What was that exam that Kirk cheated on in the original Star Trek series?
The Kobyashi Maru, or something like that?

You hit the nail on the head. A friend of mine works there and told me today
that the question was to test your reaction to stress. The answer was there
is no SQL answer but there's nothing to query. You would use Excel or some
spreadsheet.

After I sat there for 10 minutes throwing stupid ideas toward this stupid
idea, he finally asked a reasonable question...How do you find duplicates in
a list...This I could answer.

This was an interview for Marketing Analyst III...Strangest interview I've
ever been to
 
Tom said:
Dear Adam:

As you already know, you can get a set of the first set of 10 rows with TOP
10. To get a second set of 10, take the top 10 of the last 90:

SELECT TOP 10 *
FROM (SELECT TOP 90 *
FROM YourTable
ORDER BY X desc, Y desc, Z desc)
ORDR BY X, Y, Z

Then the top 10 of the bottom 80, 70, 60, . . .

Now as soon as there are not 100 rows you won't be looking for sets of 10,
but of some other size. Use:

SELECT TOP 10 PERCENT *

instead.

So, your interviewer didn't know what he was talking about. In that case,
just dazzle him with the best BS you've got. You don't score points by
making him look stupid. However, if you act like you know what you're
talking about, and let him think you think he knows what he's talking about,
that's probably the best of all possible worlds.

Now, it is about this point that I start asking myself whether I would want
to work for such an employer.

Tom Ellison
I was interviewed for a job today and they asked a question that baffled
me.
[quoted text clipped - 28 lines]
Adam Turner
Tom...I explored that avenue briefly, and afterwards decided it was hopeless..
..and yes, I'm kind of weary of working for this employer, but the job pays
very handsomely. According to my friend that works there, it's due to a high
attrition rate as a result of an extremely high stress environment.
 
.and yes, I'm kind of weary of working for this employer, but the job pays
very handsomely. According to my friend that works there, it's due to a
high
attrition rate as a result of an extremely high stress environment.

Hmm ... Doesn't that imply that lots of people think it doesn't pay
handsomely enough? :-)
 
Hmm ... Doesn't that imply that lots of people think it doesn't pay
handsomely enough? :-)


Yeah, it also implies that it doesn't take them very long to figure that
out. Figuring it out at the interview stage means the OP is ahead of the
game.
 
Back
Top