in Databases retagged by
27,672 views
39 votes
39 votes

A relational database contains two tables Student and Performance as shown below:

$$\overset{\text{Table: student}}{\begin{array}{|l|l|} \hline \text{Roll_no} & \text{Student_name}\\\hline 1 & \text{Amit} \\\hline 2 & \text{Priya} \\\hline 3 & \text{Vinit} \\\hline 4 & \text{Rohan} \\\hline 5 & \text{Smita} \\\hline \end{array}} \qquad\overset{\text{Table: Performance}}{\begin{array}{|l|l|l|} \hline \text{Roll_no} & \text{Subject_code} & \text{Marks}\\\hline 1 & \text{A} & 86 \\\hline 1 & \text{B} & 95 \\\hline 1 & \text{C} & 90 \\\hline 2 & \text{A} & 89 \\\hline 2 & \text{C} & 92 \\\hline 3 & \text{C} & 80 \\\hline \end{array}}$$

The primary key of the Student table is Roll_no. For the performance table, the columns Roll_no. and Subject_code together form the primary key. Consider the SQL query given below:

SELECT S.Student_name, sum(P.Marks) 
FROM Student S, Performance P 
WHERE P.Marks >84 
GROUP BY S.Student_name;

The number of rows returned by the above SQL query is ________

in Databases retagged by
by
27.7k views

31 Comments

5 I think.
2
2
I think it is 2 , because we needed to show the sum of marks the student got (based on the join condition we choose the student ) and when group by happens only 2 tuples remain ..
7
7
can you share the exact sql query ? I don't remember it , but all I could say is it was 5
0
0
Well I did not remember the exact complete question , therefore pardon me ,I just commented based on whatever I remembered.
0
0
....
0
0
Two roll numbered students marks were to be returned using group by clause.

Answer was 2.
0
0
As far as i remember , there was a cross join , and there was a group by , with no other condition. If this is true , then answer would be 5 , I might have missed something , kindly post the problem here if you remember
0
0
SELECT s.student_name, sum(p.marks)
FROM student s, performance P
WHERE p.marks>84
GROUP BY s.student.name
0
0
Yes in my opinion too there was no other join condition specified in the question so all tuples must be selected as the names in the first table mentioned were all distinct.
0
0
it'll be 5.
0
0
What is ur answer for predicate logic question
0
0
Actually there was roll no in both the tables over which the join would happen , which would result in 5 tuples , 2 for Amit and 3 for Raman(assumed names ),and when group by happens it would result in 2.
1
1
It was a cross join , not a natural join
0
0
Plz correct me if I am wrong but if some attribute is matching in cross product ,it is natural join by default on those attributes.
1
1
What's the purpose of explicitly mentioning natural join then in queries ? Just give commas and automatically natural join will be done.
0
0
I think There was also attribute comparison also.
0
0

SELECT s.student_name, sum(p.marks)
FROM student s, performance P
WHERE p.marks>84
GROUP BY s.student.name

@Sharad Shukla 5 can you tell me what am I missing here?

0
0
You are right. What's ur opinion on top 100, and top 200.
0
0
what about that?
0
0
Score?? what do u think ?
0
0
Which score will  be below rank 200
0
0
that for(r(),r(),r())

ques was for how many marks ?
0
0
I think 2 . Don't remember exactly .

Answer was 5 2
0
0
in some answer keys it is given 1M
0
0
This was 1 mark
0
0
ARP question was for 1 mark or 2 marks
0
0

@Ahabnnc @Deepanshu

What is answer for inherited sttribute ques ??

Q 53

And what is answer for GA question on directions ??

Q7

0
0
  1. where clause returns 

now group by 

 

0
0
arjun sir pls reply
0
0

That is on natural join, here cross product is considered as join condition is not given.

1
1
But sir,..when written in ques is join and we find two table having same attribute (here is Roll no.) ..then we do natural join . If not,plz explain.
0
0

5 Answers

46 votes
46 votes
Best answer
Group by Student_name $\implies$ number of distinct values of Student_name

in the instance of the relation all rows have distinct name then it should results $5$ tuples !
edited by

4 Comments

best solution
0
0
In the link given question there is condition given so it is natural join. But in the given question we consider as cross product.

Hope you understand.
0
0
edited by

@Shaik Masthan sir,

SELECT S.Student_name, sum(P.Marks) -----> 4.Display

FROM Student S, Performance P             ------> 1. Cross product

WHERE P.Marks >84                                  ------> 2. Conditon check

GROUP BY S.Student_name;                     -----> 3.group By

0
0
26 votes
26 votes
5 rows

Comma by default means cross product not natural join

4 Comments

Why not? I didn’t understand the concept.
0
0
For natural join it will be explicitly mentioned or we have to assume in case of same attribute name?
0
0

@Manoj Kumar Pandey

select * from (A join B on C1=C2) -------> means projection on naturnal join                                                                                             (selection on cross product)

select * from A, B ---> means projection on  cross product then projection on that

0
0
14 votes
14 votes
Remember this basic rule in sql

SELECT= PROJECTION

FROM= CROSS PRODUCT

WHERE= SELECT CONDITION

here in the given query we need to take cross product which returns 25 query with keeping in mind the condition to jave marks > 84 so when we group by our answer would be

Amit 452

Priya 452

Vinit 452

Roshan 452

Smita 452

So 5 tuples
4 votes
4 votes
was it 5 I don't remember exactly. But relation Algebra was 1

4 Comments

From where did you calculate ? Response sheet or answer key pushed ?
0
0
Good Ahbanc u will be in top २०० for sure if luck favour's u will be in top १०० , I am going down one by one , Silly mistakes of calculating combination,divide etc. ruined my exam 😑
0
0
Lets see, Even I don't know all the answers. Depends on the final answer key. Everything can change. Also, it seems this time top rankers will have very high marks so less chances it seems.
0
0
Answer:

Related questions