349 views
3 votes
3 votes

Consider the following relation.
$$\textbf{Emp}$$$$\begin{array}{|c|c|c|c|c|c|c|}
\hline
\underline{\textbf{EmpId}} & \textbf{DeptNo} & \textbf{EmpName} & \textbf{Salary} \\
\hline
1 & 5 & \text{Alex}&10,000 \\
\hline
2 & 2 & \text{Steve}&20,000 \\
\hline
3 & 1 & \text{Bob} &15,000 \\
\hline
4 & 2 & \text{Smith}&18,000 \\
\hline
5 & 4 & \text{Rakul}&24,000 \\
\hline
6 & 3 & \text{Rhea}&17,000 \\
\hline
\end{array}$$
$$\textbf{Dept}$$$$\begin{array}{|c|c|c|c|c|c|c|}
\hline
\underline{\textbf{DeptId}} & \textbf{DeptName} \\
\hline
1 & \text{CSE} \\
\hline
2 & \text{ECE} \\
\hline
3 & \text{ECE} \\
\hline
4 & \text{IT} \\
\hline
5 & \text{ME} \\
\hline
\end{array}$$
Here, Emp(DeptNo) is the foreign key referring to Dept(DeptId).

The number of tuples returned by the following SQL query is _____

SELECT max(Salary) FROM Emp, Dept
    WHERE Emp.DeptNo = Dept.DeptId group by Dept.DeptId;

1 Answer

1 votes
1 votes
We are grouping by DeptId and so 5 tuples will be returned one for each distinct DeptId.
Answer:

Related questions

1 votes
1 votes
1 answer
1
gatecse asked Oct 8, 2020
289 views
Given the following relation $R$$$\textbf{R}$$$$\begin{array}{|c|c|c|c|c|c|c|}\hline \textbf{A} & \textbf{B} \\\hline1 & \text{NULL}\\ \hline1 & \text{NULL}\\ \hline\text...
4 votes
4 votes
1 answer
2
gatecse asked Oct 8, 2020
368 views
Consider the following relation $R$$$\textbf{R}$$$$\begin{array}{|c|c|c|c|c|c|c|}\hline\textbf{A} & \textbf{B} \\\hline1 & \text{NULL} \\\hline1 & \text{NULL} \\\hline\te...
2 votes
2 votes
1 answer
3
gatecse asked Oct 8, 2020
275 views
Consider the following relation instance.$$\textbf{Student}$$$$\begin{array}{|c|c|c|c|c|}\hline \textbf{Roll}& \textbf{FirstName} & \textbf{LastName} & \textbf{Weight}\\\...
4 votes
4 votes
2 answers
4
gatecse asked Oct 8, 2020
464 views
Consider the following relations.$$\textbf{Emp}$$$$\begin{array}{|c|c|c|c|c|c|c|} \hline\underline{\textbf{EmpId}} & \textbf{DeptNo} & \textbf{EmpName} & \textbf{Salary} ...