SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


T-SQL Logic


T-SQL Logic

Author
Message
forjonathanwilson
forjonathanwilson
SSC Journeyman
SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)SSC Journeyman (81 reputation)

Group: General Forum Members
Points: 81 Visits: 33
there are no negative database ids Smile

and there is no 0

thus 1 is the answer to the most obfuscated question ever!
jvanderberg
jvanderberg
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1746 Visits: 746
Yeah, the question is overly complicated, and the answer is overly simple. The POWER() function is totally unneccessary, its fairly obvious from the WHERE clause that there's only going to be one row result. Not to mention the WHERE clause is redundant, as both branches will select the master database and only that database.

Really, I don't think it's a good question. It's complicated apparently just for the sake of being complicated. Save for learning that the database_id of the master database is always 1, no one will really actually bring anything away from this question.

--J
Toreador
Toreador
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3847 Visits: 8125
I think it's a good question - designed to make you think a bit and work out that you don't actually need to know anything about database ids in order to get it right.
Steve Cullen
Steve Cullen
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1363 Visits: 1226
Nice question. Thanks.

Converting oxygen into carbon dioxide, since 1955.


Cliff Jones
Cliff Jones
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5217 Visits: 3648
ziangij (6/22/2010)

and database_id < 2



this was enough to answer the question...:-)


Yes, if 10 would have been a possible answer it would have forced me to at least look at the rest of the Query.
Trey Staker
Trey Staker
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1622 Visits: 2788
Thanks for the question. At first glance it looked like it was going to be really difficult/complicated but ended up being simple and fun.

---------------------------------------------------------------------
Use Full Links:
KB Article from Microsoft on how to ask a question on a Forum
john.arnott
john.arnott
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3634 Visits: 3059
OCTom (6/22/2010)
And the point is?... lost on me... again.w00t

Yes, it was relatively simple to analyze, but some of the QOD's should be at an elementary level. Not all members of this community are seasoned DBAs or developers.

As a note, I often try, as I did this time, to predict an answer from the copy of the question in the email newsletter, before seeing the multiple choices. That approach does crank up a few extra brain cells.

Henrico, thanks for submitting this one. I'm taking a reminder here that sometimes it's best to break down a problem first and see if a simple component (ID < 2) will give the answer without having to delve into the complicated other parts. It's like those math riddles which have all sorts of strange stuff and end up with the anwer being zero: ((ln 23 / (19^16))*((2^3)-(64^0.5))
Dan Guzman - Not the MVP
Dan Guzman - Not the MVP
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1338 Visits: 751
I chose option 4 because I didn't know that there were no negative DB ID's. It would not be unlike MS to use negative ID's for system objects.

Now I know.
UMG Developer
UMG Developer
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4078 Visits: 2204
Interesting question, but I don't know that I would expect everyone to have the system DB IDs memorized. (Or even to know that DBs have IDs.) But given some basic understanding of the ID information the answer was very easy to pick out.
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67331 Visits: 18570
Thanks for the Question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search