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$ ?

  • $\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
    Commented Dec 31, 2016 at 8:21
  • $\begingroup$ How about trying it out? $\endgroup$ Commented Dec 31, 2016 at 8:51
  • $\begingroup$ I tried running it. But it shows different behaviour. $\endgroup$
    – Taylor
    Commented Jan 1, 2017 at 0:33

1 Answer 1


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


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