396 views

1 Answer

0 votes
0 votes

The answer is 2 as there are only 2 distinct student names.

SELECT S.studentName, Sum(p.marks) 
FROM student S, performance P
WHERE S.rollno= P.rollno

This query will return only 1 Row. Confused?

SELECT distinct S.studentName, Sum(p.marks) 
FROM student S, performance P
WHERE S.rollno= P.rollno

This will also return 1 row

SELECT S.studentName 
FROM student S, performance P
WHERE S.rollno= P.rollno

This will return 6 rows.

SELECT distinct S.studentName 
FROM student S, performance P
WHERE S.rollno= P.rollno

This will return 2 rows

 

Below is the result of the given query. Note that there are only two student names and query prints sum(P.Marks) for every student.

  Student_Name     Marks
      Raj                     310
     Rohit                   140

Related questions

0 votes
0 votes
1 answer
2
rayhanrjt asked Jan 6, 2023
719 views
Write SQL command to find DepartmentID, EmployeeName from Employee table whose average salary is above 20000.
2 votes
2 votes
1 answer
3
Subhrangsu asked Jun 18, 2022
431 views
Write SQL query to show all employees hired on June 4,1984 (non-default format)emp(empno,ename,job,mgr,hiredate,sal,comm,deptno)
1 votes
1 votes
3 answers
4
aditi19 asked May 18, 2019
1,209 views
Class(name, meets_at, room, fid)Faculty(fid, fname, deptid)Find the names of faculty members who teach in every room in which some class is taught