Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

DBMS Lecture: Order By, Functions, Aggregate, Group By, HAVING, Tables Access, Slides of Introduction to Database Management Systems

An overview of various topics in database management systems, including order by, functions, aggregate functions, group by, having, and accessing multiple tables. It includes examples of sql queries using these concepts, such as displaying student data in ascending order, using functions like upper and len, calculating averages and maximums, and joining multiple tables.

Typology: Slides

2011/2012

Uploaded on 11/03/2012

dharmaraaj
dharmaraaj 🇮🇳

4.4

(65)

153 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Database
Management
System
Lecture - 30
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download DBMS Lecture: Order By, Functions, Aggregate, Group By, HAVING, Tables Access and more Slides Introduction to Database Management Systems in PDF only on Docsity!

Database

Management

System

Lecture - 30

Order By Example

Q: Display the students’ data in the

ascending order of names

SELECT * from STUDENT

ORDER BY stName

Practice Query

Display the name and cgpa of

students for all those students

who are in second or above

semester in descending order of

names

Functions in SQL

Built-in functions are pre-written

programs to perform specific

tasks

Accept certain arguments and

return the result

Using Functions

SELECT upper(stName), lower(stFName), stAdres, len(convert(char, stAdres)), FROM student

Aggregate Function Example

SELECT avg(cgpa) as 'Average

CGPA', max(cgpa) as 'Maximum

CGPA' from student

Output is……

Group By Clause

SELECT stName, avg(cgpa) as 'Average

CGPA', max(cgpa) as 'Maximum CGPA' from student

 SELECT prName, max(cgpa) as ‘Max

CGPA', min(cgpa) as ‘Min CGPA' FROM student GROUP BY prName

HAVING Clause

We can restrict groups by using

having clause; groups satisfying

having condition will be selected

HAVING Clause

SELECT select_list [ INTO new_table ] FROM table_source [ WHERE search_condition ] [ GROUP BY group_by_expression ] [ HAVING search_condition ] [ ORDER BY order_expression [ ASC | DESC ] ]

Where and having can be combined

Accessing Multiple Tables

Cartesian Product Inner join Outer Join Full outer join Semi Join Natural Join