Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

How many rows are returned from the query below? Expand / Collapse
Author
Message
Posted Wednesday, March 3, 2010 2:29 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 10:22 AM
Points: 1,830, Visits: 6,646
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?
Post #875761
Posted Wednesday, March 3, 2010 2:34 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 4:04 AM
Points: 176, 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.
Post #875764
Posted Wednesday, March 3, 2010 2:42 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 27, 2014 5:23 AM
Points: 1,425, Visits: 1,316
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




See, understand, learn, try, use efficient
© Dr.Plch
Post #875768
Posted Wednesday, March 3, 2010 2:52 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 8:17 AM
Points: 558, Visits: 1,495
A poorly conceived question. I'm not entirely sure of the authors intention.
Post #875770
Posted Wednesday, March 3, 2010 3:13 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, December 1, 2014 7:30 AM
Points: 2,128, Visits: 5,565
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/
Post #875778
Posted Wednesday, March 3, 2010 3:14 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
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


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #875779
Posted Wednesday, March 3, 2010 3:17 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
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."
Post #875782
Posted Wednesday, March 3, 2010 3:38 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 4:20 AM
Points: 1,808, Visits: 525
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
Post #875793
Posted Wednesday, March 3, 2010 3:59 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, November 7, 2014 8:25 AM
Points: 910, Visits: 179
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.
Post #875802
Posted Wednesday, March 3, 2010 5:18 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 5:42 AM
Points: 1,287, Visits: 786
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



Post #875847
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse