Advanced SQL - LAB 1
Advanced SQL - LAB 1
Subqueries,
DCL and TCL
Statements
Variables,
Selection, and
Iteration
Stored
Procedures
Tables and
Functions
Error
Handling
Using DDL Statements The Knowledge Academy
Page | 1
Using DDL Statements The Knowledge Academy
1. Overview
The Advanced SQL course starts with an in-depth view of Subqueries, delves further
into Programmability, and completes with Error Handling and Debugging. It comprises
5 Labs –
Lab 1) Subqueries, DCL and TCL statements
Lab 2) Variables, Selection, and Iteration
Lab 3) Stored Procedures
Lab 4) Functions
Lab 5) Error Handling & Debugging.
Tasks
Subqueries
DCL Statements
TCL Statements
Page | 2
Using DDL Statements The Knowledge Academy
3. Subqueries
A subquery is a query inside a query. The inside query can return a single or multiple
values. As such, Subqueries use three operators – ALL, IN, and ANY.
3.1 The ALL Operator
The ALL operator returns a true value when the comparison being made is true for all
the values.
Find the name of the Customer who is not placing an Order.
To perform the above query follow the steps below:
From the Standard Toolbar , click the New Query Option
In the Query Window, issue the following statement
Page | 3
Using DDL Statements The Knowledge Academy
Page | 4
Using DDL Statements The Knowledge Academy
Page | 5
Using DDL Statements The Knowledge Academy
Page | 6
Using DDL Statements The Knowledge Academy
Page | 7
Using DDL Statements The Knowledge Academy
Page | 8
Using DDL Statements The Knowledge Academy
Begin Tran
Insert into Orders Values (1014, 5604,'12-Dec-2017', 8374)
Select * from Orders
Commit Tran
Page | 9
Using DDL Statements The Knowledge Academy
Begin Tran
Insert into Orders Values (1014, 5611,'12-Dec-2017', 8374)
Insert into Orders Values (1016, 5611,'12-Dec-2017', 8374)
Select * from Orders
Rollback Tran
Both the records are not inserted in this case as the two inserts are a part of a single
transaction
Page | 10
Using DDL Statements The Knowledge Academy
Page | 11