0 0 votes Consider the following relations: How many number of records will be returned by the following query? Databases databases sql made-easy-test-series + – atulcse 2.2k views answer comment Share Follow Print See all 13 Comments 13 13 Comments reply Shaik Masthan commented Jan 7, 2022 reply Follow flag count (*) - gives digit as output. it may be 0 or 1 or any other. So exists return true for every tuple. 3 3 replyShare palashbehra5 commented Jan 7, 2022 reply Follow flag Shaik Masthan That makes sense, thanks. 0 0 replyShare atulcse commented Jan 16, 2022 reply Follow flag Isn’t the first line wrong here? In SELECT T1.A, what is T1? 0 0 replyShare Isha_99 commented Jan 16, 2022 reply Follow flag I think there is R in place of T1 1 1 replyShare palashbehra5 commented Jan 16, 2022 reply Follow flag https://gateoverflow.in/369085/Made-easy-full-syllabus-test-1-sql-output 0 0 replyShare atulcse commented Jan 16, 2022 reply Follow flag Will it work if we wrote FROM R AS T1? 0 0 replyShare atulcse commented Jan 16, 2022 reply Follow flag won't count(*) return 0 because S.E > 10 is false always? 1 1 replyShare palashbehra5 commented Jan 16, 2022 reply Follow flag it will, however as a scalar quantity, which is not NULL and evaluated as TRUE for every tuple, and as a result, every tuple is selected. 1 1 replyShare amitraj123 commented Jan 17, 2022 reply Follow flag Yes, there should be “from R as T1” 0 0 replyShare juniorG commented Jan 30, 2022 reply Follow flag @palashbehra5 @Shaik Masthan what’d be the output if count(*) wasn’t mentioned in the question? would it still behave the same way? i was wondering if it’d behave like ANY/ALL in case of an empty set 0 0 replyShare palashbehra5 commented Jan 30, 2022 reply Follow flag @juniorG In that case we would get an empty set, and no tuples will be eventually returned. > i was wondering if it’d behave like ANY/ALL in case of an empty set What do you mean by this? 0 0 replyShare juniorG commented Jan 30, 2022 reply Follow flag @palashbehra5 so the answer would be zero if count(*) wasn’t mentioned? do you have any resource for this? also, ALL returns true in empty set and ANY returns false, so i thought it’d applicable here as well? https://gateoverflow.in/95059/Working-of-any-and-all-with-empty-set 0 0 replyShare palashbehra5 commented Jan 31, 2022 reply Follow flag @juniorG Not a resource really but for most the SQL doubts, use any online SQL query interpreter. Now, without count. The only reason behind it that the type of output inner queries give in both cases. in the case of count(*), the inner query returns a scalar quantity, which is not empty but in the second case where it was supposed to return tuples, it returns an empty set. > also, ALL returns true in the empty set, and ANY returns false, so I thought it’d be applicable here as well? Yes, sort of. EXISTS with an empty set will select no tuples and NOT EXISTS will select tuples for an empty set. 0 0 replyShare Please log in or register to add a comment.
1 1 vote Answer should be zero. It is a co-related query. So for every tuple of R, we have to execute a co-related query. Condition S.E>10 is always false, and it is with and condition, so count(*) will return 0, and exist will return false to R each tuple. So 0 record will be selected. Answer- 0 Record amitraj123 answered Jan 17, 2022 amitraj123 comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes see count(*) will always return something and in this case returning 0.So exists return true..So thats why every tuple will get selected from table R samarpita answered Jan 31, 2022 samarpita comment Share Follow 0 reply Please log in or register to add a comment.