You have the database table named Cars as defined below: You have the following Structured Query
Language (SQL) statement:
How many rows are returned by the SQL statement?
A.
4
B.
5
C.
6
D.
7
You have the database table named Cars as defined below: You have the following Structured Query
Language (SQL) statement:
How many rows are returned by the SQL statement?
A.
4
B.
5
C.
6
D.
7
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
Jared you are correct. Answer is 7.
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’)
correct ans is 4 according to given query
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.
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
Yes, awnser is 4. The return values MAY NOT be USA AND may not be BLACK.
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.
Number of rows DIFFERENT from USA = 6 then you add the and DIFFERENT BLACK, and its 7, how come 4 ??? It would be 4 if we have there and OR instead AND
I typed in the SQL and tried it myself.
With OR, you get 7. With AND, you get 4. Sedan, Mini, Hybrid, and SUV.