Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How many rows are returned from the query below?


How many rows are returned from the query below?

Author
Message
Toreador
Toreador
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2417 Visits: 8064
Aam-624390 (3/3/2010)
Seems to be a lot missing assumptions.


Well it seems a reasonable assumption that tblUsers exists, and is a table.
You then have to guess about data volumes - I thought that since a system generally has more than one user it was reasonable to assume that there were at least 2 rows.

Having made those assumptions then there could only be one answer - but I'm not sure what the question was meant to demonstrate? Did those who got it wrong just make different assumptions?
Open Minded
Open Minded
SSC-Enthusiastic
SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)SSC-Enthusiastic (182 reputation)

Group: General Forum Members
Points: 182 Visits: 567
I think this was about cross join?

I use these kind of statements to generate the possible valid sales of products against a table of customers. The generated table/view becomes the 'pigeonhole' to hold incoming, actual sales.
honza.mf
honza.mf
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1771 Visits: 1323
Toreador (3/3/2010)
Aam-624390 (3/3/2010)
Seems to be a lot missing assumptions.


Well it seems a reasonable assumption that tblUsers exists, and is a table.
You then have to guess about data volumes - I thought that since a system generally has more than one user it was reasonable to assume that there were at least 2 rows.

Having made those assumptions then there could only be one answer - but I'm not sure what the question was meant to demonstrate? Did those who got it wrong just make different assumptions?


Assumptions above are reasonable but not absolute. "tblAnything" can be a view. System may have many users but under some conditions the table will be empty.
Author is not able to fix conditions by using either temporary table or some system table (view).
I think that nobody will argument that there is no sysdatabases and it can be empty. Maybe some Oracle or HisSQL user :-P



See, understand, learn, try, use efficient
© Dr.Plch
Chris Houghton
Chris Houghton
SSChasing Mays
SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)SSChasing Mays (622 reputation)

Group: General Forum Members
Points: 622 Visits: 1664
A poorly conceived question. I'm not entirely sure of the authors intention.
Adi Cohn-120898
Adi Cohn-120898
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2224 Visits: 6079
I agree with the posters that claim that the question had more then 1 answer that could be correct. I guessed the answer because I assumed that the table exists and that it has more then 1 record. The fact that we need to make any assumptions means that the question should be re written. Especially when all the given answers could be correct with different assumptions.

Adi

--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
free_mascot
free_mascot
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2879 Visits: 2235
Question asked do not mention anything about table tblUsers

When executed the query ;

WITH Users(UserID, UserName) AS
(
SELECT TOP 1 intUserID, strUserName FROM tblUsers
)
SELECT TOP 2 tblUsers.*, Users.* FROM tblUsers, Users

Reults into following error:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'tblUsers'.

Looks like other's have also faced the same issue here Hehe

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
free_mascot
free_mascot
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2879 Visits: 2235
Author could have eliminate the answer option "Error Message" from Question.

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
kaspencer
kaspencer
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2388 Visits: 814
OBJECTION! OBJECTION! OBJECTION!

Yet another useless question.
I knew I had no table named "tblUsers", and so I answered "Error Message".
And I was correct - that was the answer I got.

I demand my point. And I also demand, yet again, that standards are improved regarding the quality of these questions, and the background information to be supplied before they should be run.

And to the Question Mmoderators: do your job. Your reputation is now properly in the gutter.

Kenneth Spencer

You never know: reading my book: "All about your computer" might just tell you something you never knew!
lulu.com/kaspencer
simon.whale
simon.whale
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1168 Visits: 216
After researching i dont think it is a stupid question, just an incomplete question. As its a cartesian join (if the CTE is relevant im not sure!?!?)

just that he / she forgot to include the create table statement for tblusers.
Robbert Hof
Robbert Hof
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: 1288 Visits: 834
I created a table tblUsers and inserted some data.
The query failed with this error:

Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'WITH'.

I am using SQL Server 2000.
On SQL Server 2005 no errors where displayed (2 rows).

mmmmm, bad question for earning points, good question for learning

Robbert



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