PrepAway - Latest Free Exam Questions & Answers

10 Comments on “How many rows are returned by the SQL statement?

  1. Jared says:

    Isn’t the right answer 7 because is not equal to right. So the only row that would be excluded would be the convertible Black USA because there is an AND not a OR. If it was Or c.color black then I would see that 4 is correct




    3



    0
      1. Borik says:

        Correct Answer is 4, Maybe this will help,

        Following 2 queries produce same result:

        Select * from cars c where c.origin ‘usa’ and c.color ‘black’

        Select * from cars c where not(c.origin = ‘usa’ or c.color = ‘black’)




        2



        3
  2. Caleb Unwin says:

    The correct answer is 4. You are saying It cannot be black AND it cannot be from the USA. Even though in english you would say ‘It can’t be black or American’, it is different in SQL here.
    I built the table and ran the query.




    2



    2
  3. jaspreet says:

    correct answer is 4, it checks on origin and then on color, so it is removing those records which are containing USA origin, and it is also removing those records which are containing black color. it is bit hard to understand but make a table try to run the query




    1



    0
  4. Andrei says:

    if we just run origin usa the result will be 6, and when we add black, then we need to add one more record, the correct answer is 7, because the and, the 2 conditions must match to discard the row.




    1



    0

Leave a Reply