Query output:

The answer is given as 7,Shouldn't be 3.As A,D,J has rank>=3.

9Comments
Arul @innovwelt
20 Jan 2015 08:09 pm

I understand the query as select all the names where "the number/count of distinct ranks less than his rank is <= 3"

rank count of distinct ranks less than me
1 0 (selected)
2 1 (selected)
3 2 (selected)
4 3 ( selected)

So, All names needs to be selected?

Mahesh Kumar @maheshkumars
20 Jan 2015 08:32 pm

I think it should be "Select all the names where "the number of distinct ranks less than his rank is >= 3"

WHERE 3>= (SELECT .....).In this the where condition is true only if the select query returns value greater than or equal to 3.Is it ok for u?

 

Arul @innovwelt
20 Jan 2015 08:44 pm

I think, the reverse is true.

3 >= select...

3 is greater than or equal to "select count" .... i.e., "select count" is less than or equal to 3

Mahesh Kumar @maheshkumars
20 Jan 2015 09:11 pm

3 is greater than or equal to "select count" . "select count" is less than or equal to 3 <-- it is the converse of the first statement,Converse of a statement is not always TRUE right?

Arul @innovwelt
20 Jan 2015 10:17 pm

well, It depends on the context.  :)

here, let's consider an example. let the result of select is 2.

i.e., 3 >= 2 implies 2 <= 3

Mahesh Kumar @maheshkumars
20 Jan 2015 11:13 pm

ok bro.If u have time just check it and reply ,i dont have DBMS.

Anjan @prab_1
13 Dec 2015 08:25 pm

@pritam sir Please explain what the inner query do ??

Pritam Prasun @pritam
13 Dec 2015 08:37 pm

It's correlated nested query so, inner query doesn't do anything alone. 

Parimal Andhalkar @parimal_andhalkar
13 Dec 2015 10:17 pm

All tuples gets added into the result.

Pages