QUERY FORMULATION WITH SQL, Slides of Database Management Systems (DBMS)

this document contains detailed explanation for beginners..it has covered each and every topic in details for those who are eager to learn data base management system.

Typology: Slides

2021/2022

Available from 08/19/2022

SamenKhan
SamenKhan 🇵🇰

231 documents

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Database Systems
Lecture #5
Topic: Query Formulation with SQL
Instructor: Lecturer Ayesha Naseer
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download QUERY FORMULATION WITH SQL and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Database Systems

Lecture # Topic: Query Formulation with SQL Instructor: Lecturer Ayesha Naseer

Scope of SQL

  • SQL was designed as a language for database definition, manipulation, and control.

Getting Started with SELECT Statement

  • The SELECT statement supports data retrieval from one or more tables.
  • The SELECT statement described here has the following format:

Table Creation

Create Table Student ( StdSSN VarChar(30) Primary Key, StdFirstName Char(15), StdLastName Char(15), StdCity Char(20), StdState Char(6), StdZip VarChar(30), StdMajor Char(15), StdClass Char(6), StdGPA Float );

INSERT Statement

Insert Into <Table-name> Values (column 1 value, column 2 value …) Insert Into Student Values (‘123- 45 - 6789’, ‘HOMER’, ‘WELLS’, ‘SEATTLE’, ‘WA’, ‘98121-1111’, ’IS’, ‘FR’, 3.00)

Show specific columns

  • List name, city and grade of all students. Select StdFisrtName, StdLastName, StdCity, StdCGPA From Student

Distinct Rows

Std Student StudentStudent Std^ Std^ Std Std (^) Std (^) Std Std Std Student^ Student Student

Expression in SELECT and WHERE

‘31-Dec-1996’

LIKE operator in WHERE Clause

Testing for NULLS

Complex Logical Condition In WHERE CLAUSE

ORDER BY with two Columns

Group by Clause

  • The GROUP BY and HAVING clauses are used to show results about groups of rows rather than individual rows.
  • GROUP BY reminder The columns in the SELECT clause must either be in the GROUP BY clause or be part of a summary calculation with an aggregate function.