in Unknown Category retagged by
1,891 views
0 votes
0 votes

Consider the following tables (relations):

Students
Roll-No Name
18CS101 Ramesh
18CS102 Mukesh
18CS103 Ramesh

 

Performance
Roll-No Course Marks
18CS101 DBMS 60
18CS101 Compiler Design 65
18CS102 DBMS 80
18CS103 DBMS 85
18CS102 Compiler Design 75
18CS103 Operating System 70

 

Primary keys in the tables are shown using underline. Now, consider the following query:

SELECT S.Name, Sum (P.Marks) FROM Students, Performance P WHERE S.Roll-No=P.Roll-No GROUP BY S.Name

The number of rows returned by the above query is

  1. $0$
  2. $1$
  3. $2$
  4. $3$
in Unknown Category retagged by
by
1.9k views

2 Comments

It will return 2 rows
0
0
2 rows
0
0

1 Answer

0 votes
0 votes

Answer is (C) 2

The Below Query will return 2 rows

SELECT S.Name, Sum (P.Marks)as Marks FROM Students, Performance P WHERE S.Roll-No=P.Roll-No GROUP BY S.Name

Since, Here Grouping is on S.Name

So, Output will be as below

Name         Marks

Ramesh      280

Mukesh      155

If the query will be as below then we get 3 rows

SELECT S.Roll-No, S.Name, Sum (P.Marks) as Marks FROM Students, Performance P WHERE S.Roll-No=P.Roll-No GROUP BY S.Roll-No, S.Name

Output of the above query by using the given tables in the question output will be as below

Roll-No                Name                Marks

18CS101            Ramesh              125

18CS102            Mukesh              155

18CS103           Ramesh              155

by

Related questions