0% found this document useful (0 votes)
3 views

Worksheet Week3-1

these are sql questions. sql is an important query language in computer science.

Uploaded by

himansipowers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Worksheet Week3-1

these are sql questions. sql is an important query language in computer science.

Uploaded by

himansipowers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DBMS Lab Task

WEEK-3 Group by, having, order by and Aggregate Functions


The GROUP BY clause is used in conjunction with aggregate functions such as MIN() and MAX(), SUM() and
AVG(), COUNT(), etc.
SQL aggregate functions are used to calculate a single value from a set of values.
The following are the commonly used SQL aggregate functions:
These functions are often used with the GROUP BY clause of the SELECT statement. The GROUP
BY clause divides the result set into groups of values and the aggregate function returns a single value
for each group.
Various Aggregate Functions
1) Count() : Returns total number of records

2) Sum(): Sum all Non Null values of Column

3) Avg():returns the average of all values in the column.

4) Min():Return Minimum value in the column except NULL

5) Max():Return Maximum value in the column except NULL

1.Create the following table Student(sid, sname, sbranch, DBMS, DAA, COA, TOC, OOPS,
stotal, scgpa) and answer the following questions.
Guidelines:
Enter Marks of subjects between 0-50 for each, treat <17.5 as failed and >17.5 as passed.
Enter ‘NULL’ for few subjects’ marks and treat it as student is absent.
Enter other Branches other than ‘CSE’

a. Count the no.of students in the student table.


b. Display the sum of DBMS marks of students whose marks are less than 17.5
c. Display the count of students who failed DBMS(<17.5)
d. Display sid, sname of student who gets Maximum marks in DAA.
e. Dispay Sid,sname,scgpa of students who gets minimum marks in OOPS.
f. Display Average marks in DBMS.
g. Display sid,sname,OOPS,DAA of students who failed in DAA and Passed in OOPS.
Dept. of CSE, NIT Andhra Pradesh 1
h. Display Minimum and maximum marks in All the 5 subjects.
i. Display the count of Non CSE students in the table.
j. Display the count of students whose CGPA>8.0.
k. Display count of students whose stotal marks are >350.
l. Display sum of OOPS marks of students whose CGPA<6.0.
m. Display the count of students who failed in TOC and passed in COA.
n. Display the count of students Who passed in All Exams.

2. Answer the following Questions


a. Display the Subject wise failed count of students
b. Display Subject wise Maximum marks of all Subjects.
c. Display Subject wise Minimum marks of all Subjects.
d. Display Branch wise student count
e. Display Subject wise Absents count
f. Display Branch wise failure count
g. Display Branch wise Maximum and Minimum CGPA of Students
h. Display Branch wise Absentees count
i. Display Subject wise sum of marks of students
j. Display Branch wise Sum of Marks of students
k. Display Subject wise Maximum marks for all Subjects whose maximum marks >35.
l. Display Subject wise Minimum marks for all Subjects whose minimum marks >17.5 and the
marks are in descending order.
m. Display Subject wise average of marks of students whose average of marks>30 and marks
are in Ascending order.
n. Display Branch wise Maximum and Minimum CGPA of Students whose CGPA>6.0 and
CGPA in descending order.
o. Display Branch wise failure count whose count >4 and count in the descending order.
p. Display sid,same,cgpa in the descending order of scgpa.
q. Display Sid,sname,stotal,scgpa in the descending order of stotal
r. Display Subject wise names whose name has maximum charecters.
s. Display branch wise Sid who got maximum CGPA
t. Display Subject wise sid who got Maximum marks

Dept. of CSE, NIT Andhra Pradesh 2

You might also like