-2
$\begingroup$

Suppose I have a relation R

enter image description here

How many tuples are returned by SQL query

SELECT distinct manager FROM R

Is it $2$ or $4$ ?

$\endgroup$
  • $\begingroup$ What have you tried? Where did you get stuck? We do not want to just hand you the solution; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. See here for tips on asking questions about exercise problems. If you are uncertain how to improve your question, why not ask around in Computer Science Chat? $\endgroup$ – Raphael Dec 31 '16 at 8:21
  • $\begingroup$ How about trying it out? $\endgroup$ – Yuval Filmus Dec 31 '16 at 8:51
  • $\begingroup$ I tried running it. But it shows different behaviour. $\endgroup$ – mcjoshi Jan 1 '17 at 0:33
2
$\begingroup$

You will get 2 records, with value 2 and null

NULL is still a value when it comes to distinct, but it is not included if you do a count, so

select count(manager) from r;

would just return a count of 1

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.