2.2-DQL Adc
2.2-DQL Adc
MSIT 2k23
LECTURE OUTLINE
SQL-Introduction
Data Query Language (DQL)
SELECT
WHERE
FROM
GROUP BY
HAVING
2
SQL INTRODUCTION
MYSQL & SQL
4
5
DQL || DRL
6
DATA QUERY LANGUAGE
8
SQL SYNTAX
9
EXAMPLE
10
SQL WORK FLOW
11
OTHER ASPECT OF SQL
12
SQL –DML / DQL
13
SELECT CLAUSE
14
SELECT CLAUSE EXAMPLE
15
SELECT CLAUSE EXAMPLE
16
FROM CLAUSE
17
FROM CLAUSE EXAMPLE
18
FROM CLAUSE EXAMPLE
19
WHERE CLAUSE
20
SCALAR EXPRESSION IN SQL
21
WHERE CLAUSE EXAMPLE
22
PATTERN MATCHING
23
PATTERN MATCHING
24
PATTERN MATCHING -EXAMPLE
25
ESCAPE CHARACTER
ESCAPE CHARACTER
GROUP BY AND HAVING
GROUP BY CLAUSE
SPLIT APPLY COMBINE
POINT TO REMEMBER
GROUP BY CLAUSE- EXAMPLE
HAVING CLAUSE
HAVING CLAUSE- EXAMPLE
GROUP BY AND ORDER BY
GROUP BY AND HAVING
Relation b/w COUNT, NULL, DISTINCT, ALL
Test Case#1: Count(*); NULL in Salary
Conclusion: Count ignores “NULL” and don’t put it into consideration while counting.
Relation b/w COUNT, NULL, DISTINCT, ALL
Test Case#3: Count(DISTINCT Salary); NULL in Salary
Conclusion: Count ignores “NULL” and don’t put it into consideration while counting whether
DISTINCT is being used or not.
Relation b/w COUNT, NULL, DISTINCT, ALL
Test Case#4: Count(ALL Salary); NULL in Salary
Conclusion: Count ignores “NULL” even if ALL is used. In fact, use of ALL is not making any sense
in here and the query behaves same without ALL.
Revisit!
Conclusion: GRIOUP BY can work without aggregated attribute and vice versa
Relation b/w GROUP BY, HAVING &
Aggregated Attribute
Test Case#2: GROUP BY with Aggregated Attribute