How many rows are returned from the query below?

  • Ashka Modi

    Old Hand

    Points: 377

    Comments posted to this topic are about the item How many rows are returned from the query below?

    Thanks,

    Ashka Modi
    Software Engineer || credEcard Technologies (india) Pvt. Ltd.

  • Joy Smith San

    SSC-Insane

    Points: 24875

    I got an error when I tried in SQL Server 2005...!!!

  • mandarkavishwar

    SSC Veteran

    Points: 243

    That query gives perfect result.

    Thanks.

    Mandar Kavishwar.

    EC Infosolution

  • Joe SQL

    SSChasing Mays

    Points: 620

    Seems to be a lot missing assumptions. Each given answer can be correct given different starting conditions.

    Running the code as-is got me an error first (tblUsers does not exist. doh!).

    I then created the table and got 0 rows as the result.

    I added 1 row and got 1 row as the result.

    Added another row and got 2 rows as the result.

    Adding more rows kept the result at 2 rows.

  • honza.mf

    SSCertifiable

    Points: 5519

    WTF is tblUsers?

    It can be a table or a view or nothing.

    If it is anything defined (table or view) it can be empty (0 rows returned), it can contain just 1 row (1 row returned) or it can contain more rows (2 rows returned).

    With these assumptions - three answers possible - tblUsers is undefined and the script returns an error message. QED



    See, understand, learn, try, use efficient
    © Dr.Plch

  • ziangij

    SSCertifiable

    Points: 6548

    i fail to understand what is the learning in this question. anybody plz. suggest...

  • ziangij

    SSCertifiable

    Points: 6548

    if the query contains a top 3

    SELECT top 3 c.*, Users.* FROM reptec_changedim c, Users

    then this will return 3 records...

  • simon.whale

    Ten Centuries

    Points: 1393

    I get an error saying tblUsers doesn't exist.. Is this a Version issue or missing information? im on SQL 2005

  • nigel.

    SSChampion

    Points: 11481

    Aam-624390 (3/3/2010)


    Seems to be a lot missing assumptions. Each given answer can be correct given different starting conditions.

    Agreed, question is incomplete and I fail to see the point of it.

    --
    Nigel

  • nigel.

    SSChampion

    Points: 11481

    ziangij (3/3/2010)


    i fail to understand what is the learning in this question. anybody plz. suggest...

    No idea!!!! :w00t:

    --
    Nigel

  • Toreador

    SSChampion

    Points: 11223

    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

    SSCommitted

    Points: 1842

    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

    SSCertifiable

    Points: 5519

    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

  • Chris Houghton

    SSCrazy

    Points: 2446

    A poorly conceived question. I'm not entirely sure of the authors intention.

  • Adi Cohn-120898

    SSC-Dedicated

    Points: 33944

    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/

Viewing 15 posts - 1 through 15 (of 111 total)

You must be logged in to reply to this topic. Login to reply