6 votes 6 votes Plz explain both queries! Databases databases sql + – Lokesh . asked Jan 12, 2017 retagged Aug 5, 2017 by Arjun Lokesh . 1.2k views answer comment Share Follow See all 18 Comments See all 18 18 Comments reply Ajay Jadhav commented Jan 13, 2017 reply Follow Share I think both queries won't work whats the answer 0 votes 0 votes Lokesh . commented Jan 13, 2017 reply Follow Share ans given is Q1 0 votes 0 votes dd commented Jan 13, 2017 i edited by dd Jan 13, 2017 reply Follow Share Q1 : Assuming CSE branch student exist in the database table Student. A tuple $t_1$ from Student table will be included in the result of Q1, when the corresponding inner query result is empty. if $t_1$.$\text{rank}$ is less than the all CSE student ranks,then only inner query results becomes empty. Q2: If CSE dept ranks are = $\left \{ 4,5,6,7 \right \}$ A tuple $t_1$ from Student table will be included in the result of Q2, when $t_1$.$\text{rank}$ is less than any one of $\left \{ 4,5,6,7 \right \}$. Obviously CSE topper will not be in the result of Q2 0 votes 0 votes Lokesh . commented Jan 13, 2017 reply Follow Share this means Q1 is wrong?? 0 votes 0 votes dd commented Jan 13, 2017 reply Follow Share I think wrong ! What you say ? 0 votes 0 votes Lokesh . commented Jan 13, 2017 reply Follow Share in question they are asking anyone...but here we are getting all...I selected none but they gave q1 as ans thats why I asked here 0 votes 0 votes dd commented Jan 13, 2017 reply Follow Share what is wrong in my comment above ? for Q2 ? 0 votes 0 votes Rahul Jain25 commented Jan 13, 2017 reply Follow Share This is basically a gate question that has been asked previously but relation names and scenario has been changed. And Q1 is correct. @Arjun sir has explained that question brilliantly. You could refer that. https://gateoverflow.in/1259/gate2007-61 0 votes 0 votes Lokesh . commented Jan 13, 2017 reply Follow Share its correct but in ANY when inner query returns empty ...then result will be false thats why I think Q2 is also incorrect 0 votes 0 votes Samujjal Das commented Jan 13, 2017 reply Follow Share They tried to copy this question with a little modification and failed horribly :p https://gateoverflow.in/1259/gate2007-61 0 votes 0 votes Rahul Jain25 commented Jan 13, 2017 reply Follow Share Q2 is definately wrong bcoz it will give even that person which has rank less than even one individual of CS, but we want only those person who have rank smaller than all individuals of CS. Q1 is the answer. Remember here we want persons whose rank is smaller than everyone in CS. 0 votes 0 votes dd commented Jan 13, 2017 reply Follow Share @rahul you could say ..our interpretation for "anyone" was wrong in the particular QS. Thanks for the QS link quoting from that QS comments: anyone here refers = everyone in the CSE dept. right ? @rahul ? 0 votes 0 votes Rahul Jain25 commented Jan 13, 2017 reply Follow Share It don't think they have failed in changing this question. I find this questions correct and Q1 as the only answer. 1 votes 1 votes Rahul Jain25 commented Jan 13, 2017 reply Follow Share @dbashish, yes. I will say again go the link. There one comment is done by arjun sir, really an excellent one, where he has used a set and explained what anyone means. Read all comments. 1 votes 1 votes Samujjal Das commented Jan 13, 2017 reply Follow Share Yes correct. I said so seeing the discussions going on here previously. Sorry!! 0 votes 0 votes akshay_845 commented Jan 25, 2017 reply Follow Share @habibkhan can you tell me this 0 votes 0 votes joshi_nitish commented Jul 9, 2017 reply Follow Share why are you mentioning my name here??..i hadn't commented or answered here.... are you asking me to verify this??? 0 votes 0 votes joshi_nitish commented Jul 9, 2017 reply Follow Share see, neither "s2.rank<=s1.rank" nor "s2.rank<s1.rank" will work... in case of "s2.rank<=s1.rank"...s1 will be selected only if it is less than everyone...moreover there is one more problem in this query, 'what if s1 is from CSE department, than he will never get selected because there will come a point where comparison s1.rank<=s1.rank will be done and therefore notexist will contain some tupple and s1 will not be selected... in case of "s2.rank<s1.rank"...s1 will not be selected if it is greater than anyone in cse(or we can say s1 will be selected only if it less than or equal to everyone)... 0 votes 0 votes Please log in or register to add a comment.