edited by
934 views
3 votes
3 votes

Consider the following Relation $\text{employee}$:
$$\begin{array}{|l|l|l|} \hline \text{eno} & \text{ename} & \text{manager} \\ \hline 1 & \text{satish} & \text{rajeev} \\ 2 & \text{naveen} & {} \\ \hline 3 & \text{murali} & \text{rajeev} \\ \hline 4 & \text{srinu} & {} \\ \hline 5 & \text{brahma} & {} \\ \hline \end{array}$$
How many number of tuples will be output after executing the following query?

SELECT DISTINCT(manager) FROM  employee;
  1. $1$
  2. $2$
  3. $4$
  4. $5$
edited by

2 Answers

2 votes
2 votes
Here number of distinct manager is $2$ because $1$ is rajeev and another one is NULL. In sql NULL is treated as one distinct element.
1 votes
1 votes

When the value of an attribute isn't specified, it takes the value "NULL".

NULL indicates that the value might be absent for the attribute, or if present, is unknown. (Hence a NULL == some other NULL isn't True)

 

But the DISTINCT keyword distinguishes by text, and not values. So,

  • NULL and NULL would not be considered distinct.
     
  • Rajeev and rajeev would've been considered distinct (DISTINCT isn't case sensitive by default)

 

Here, we have two distinct values for the managers "attribute" — rajeev and NULL.

 

So, 2

Answer:

Related questions

1 votes
1 votes
1 answer
2
Applied Course asked Jan 16, 2019
485 views
Consider the relation Parts $\text{(Partno, SupplierID, Partname, Model)}$, with $\text{{Partno, SupplierID}}$ as the primary key. Suppose the following functional depend...
1 votes
1 votes
1 answer
4