All Exams Test series for 1 year @ ₹349 only
Question

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 S, Performance P

WHERE S.Roll-No = P.Roll-No

GROUP BY S.Name

The number of rows returned by the above query is

The correct answer is

2

GROUP BY S.Name creates one group for each distinct name in the joined rows. The two groups are Ramesh, with total marks 60 + 65 + 85 + 70 = 280, and Mukesh, with total marks 80 + 75 = 155. Hence the query returns 2 rows.

Was this answer helpful?

Important Questions from SQL

  1. Match the following -

    List IList II
    (a)DDL(i)LOCK TABLE
    (b)DML(ii)COMMIT
    (c)TCL(iii)Natural Difference
    (d)Binary operation(iv)REVOKE
  2. Which of the following is NOT a Structured Query Language Data type?

  3. Consider the following relational schema:
    Students (rollno: integer, name: string, age: integer, cgpa: real)
    Courses (courseno: integer, cname: string, credits: integer)
    Enrolled (rollno: integer, courseno: integer, grade: string)
    Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?

  4. Consider a table Employee(EmpID, TeamID), where the column EmpID (ID of an employee) is the primary key. The column TeamID denotes the team ID of the team of which the employee is a member. TeamID is a NOT NULL column.

    We want to display the size of the team (denoted as TeamSize) in which each employee is a member by using SQL. As an example, the desired output for the given Employee table is also shown in tabular form.

    Which of the following is/are correct?

    Employee
     

    EmpIDTeamID
    18
    28
    38
    47
    57
    69



    Output
     

    EmpIDTeamSize
    13
    23
    33
    42
    52
    61
  5. Let Account be a relation as shown. 

                                                                                                             Account

    AccNoBalance
    A15000
    A25000
    A310000
    A415000
    A518000

    Consider the given SQL query.

    SELECT AccNo FROM Account AS A 

    WHERE (SELECT COUNT(*) FROM Account AS B  

    WHERE A.Balance < B.Balance) >= (SELECT COUNT(*)  

    FROM Account AS C WHERE A.Balance > C.Balance)

    The number of rows returned by the SQL query is __________ . (Answer in integer)

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App