SlideShare a Scribd company logo
1 of 20
Database
Information Technology Management Dept.
Third Stage
2022-2023
Lecture 2
A.Lecturer: Nareen O.Muhamad
Email: nareen.mohameed@dpu.edu.krd
Objectives
 After completing this lesson, you should be able to do the following:
 List the capabilities of SQL SELECT statements Execute a basic SELECT
statement this include:
 Using Arithmetic Expressions
 Selecting All OR Specific Column(s).
 Defining a Null Value.
 Defining a Column Alias
 Eliminating Duplicate Rows
What is Structured Query Language?
 SQL stands for Structured Query Language.
 It is the language that is used to extract, manipulate,
and structure data that resides in a Relational
Database Management System (RDBMS). In other
words, to get an answer from your database, you must
ask the question in SQL.
Model Microsoft SQL Server
 Microsoft SQL Server is a relational database language
based on the SQL .
 Microsoft SQL Server contains two kinds of statements:
 Data Definition Language (DDL) statements. These
statements let you define and modify the schema of your
database.
 Data Manipulation Language (DML) statements. These
statements let you create, access and modify data in your
database.
Data Definition Language (DDL)
Statement Description
CREATE TABLE Defines a table in a database.
DROP TABLE Deletes a table from a database.
ALTER TABLE Modifies a table in a database.
CREATE INDEX Adds an index to a table.
DROP INDEX Deletes an index from a table.
Data Manipulation Language (DML)
Statement Description
SELECT
Retrieves and displays one or more rows from a
table.
INSERT INTO Adds new rows to a table.
UPDATE Changes column values in one or more rows of a
table.
DELETE FROM Deletes one or more rows from a table.
UNION
Combines two or more SELECT statements to
create
a complex query.
Table
 In a relational database, all data is organized into tables.
 Tables are the database structure that contains the
physical data, and they are organized by their columns
(or fields) and rows (or records).
Creating and Working with tables
 Creating employees table and establish primary key
constraints. In SQL Server, tables can be created
graphically using SQL Server Management Studio
(SSMS) or using a query(Learned Later).
Capabilities of SQL SELECT statements
 A SELECT statement retrieves information from the database. Using a
SELECT statement as the following:
1. Projection: choose (few or as many) the columns in a table
to returned by a query.
2. Selection: choose the rows in a table to returned by a query.
Various criteria used to restrict the rows.
3. Joining: it brings together data that is stored in different
tables by creating a link between them (learned later).
Basic SELECT Statement
1- Selecting All Columns
 SELECT * FROM employees
 An asterisk (*) displays all columns of the table
 Or all table fields can be written.
 SELECT Employe_ID, First_Name, Last_Name,
Phone_Number, Address, Salary, Hier_Date,
Department_Name FROM employees
 It Selects All Columns of All Rows
2-Selecting Specific Columns
• SELECT Employe_ID, Last_Name FROM employees
• It Selects Specific Columns of All Rows
• Columns order can be specified in which you want them to appear
in the output, Such that:
Arithmetic Expressions
 Multiplication and division are evaluated first.
 Same priority Operators are evaluated from left to right.
 Parentheses are used to force prioritized evaluation and to clarify
statements.
 SELECT Last_Name, Salary, Salary +300 From
employees
 The calculated column (SALARY+300) is not a new
column in the EMPLOYEES table.
 By default, the name of a new column comes from the
generation of ( salary+300).
Using Arithmetic Expressions
Operator Precedence
 SELECT last_name,salary, 12*salary+100
From employees
The (*) performed before (+).
 SELECT last_name,salary, (12*salary)+100
From employees
 SELECT last_name,salary, 12*(salary+100)
From employees
 First to force the expression. Second override the rules of
precedence
Defining a Null Value
 If a row lacks the data value for a particular column, that value is said
to be NULL, or to contain a NULL.
 A NULL is a value that is unavailable, unassigned, unknown, or
inapplicable.
 Zero is a number, and a space is a character.
 A NULL is not the same as zero or a blank space.
 SELECT last_name, Salary, salary, 12*salary FROM employees
Null Values - in Arithmetic Expressions
 If any column value in an arithmetic expression is
NULL, the result is NULL.
 Performing division with zero, it gets an error.
 Dividing a number by null, the result is a null or
unknown.
 SELECT last_name, 12*salary*commission_pct
FROM employees
Defining a Column Alias
A column Heading Alias:
 Renames a column heading, is useful with calculations.
 Immediately follows the column name.
 Optional AS keyword used between the column and
alias.
 Requires double quotation marks if it contains spaces or
special characters (# or $).
It can be used in both the SELECT and the ORDER BY
clause. It cannot be used in the WHERE clause.
Using Column Aliases
SELECT last_name AS name , Department_Name Dept
FROM employees
SELECT last_name "Name ", salary*12 "Annual Salary"
FROM employees
Eliminating Duplicate Rows
 The default display of queries is all rows, including duplicate
rows.
 SELECT department_NameFROM employees
 Eliminate duplicate rows by using the DISTINCT keyword
in the SELECT clause.
 SELECT DISTINCT department_Name FROM employees
lect 2.pptx

More Related Content

Similar to lect 2.pptx

DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
 
Sql intro
Sql introSql intro
Sql introglubox
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sqlN.Jagadish Kumar
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfTamiratDejene1
 
Oracle Baisc Tutorial
Oracle Baisc TutorialOracle Baisc Tutorial
Oracle Baisc Tutorialbunny0143
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIMsKanchanaI
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETEAbrar ali
 
Basic SQL Statments
Basic SQL StatmentsBasic SQL Statments
Basic SQL StatmentsUmair Shakir
 
MS SQLSERVER:Retrieving Data From A Database
MS SQLSERVER:Retrieving Data From A DatabaseMS SQLSERVER:Retrieving Data From A Database
MS SQLSERVER:Retrieving Data From A Databasesqlserver content
 
MS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A DatabaseMS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A Databasesqlserver content
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankpptnewrforce
 

Similar to lect 2.pptx (20)

DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
 
Sql intro
Sql introSql intro
Sql intro
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
Lab
LabLab
Lab
 
Oracle Baisc Tutorial
Oracle Baisc TutorialOracle Baisc Tutorial
Oracle Baisc Tutorial
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
Basic SQL Statments
Basic SQL StatmentsBasic SQL Statments
Basic SQL Statments
 
SQL Query
SQL QuerySQL Query
SQL Query
 
Assignment#02
Assignment#02Assignment#02
Assignment#02
 
Teradata imp
Teradata impTeradata imp
Teradata imp
 
01 basic orders
01   basic orders01   basic orders
01 basic orders
 
[PHPUGPH] PHP Roadshow - MySQL
[PHPUGPH] PHP Roadshow - MySQL[PHPUGPH] PHP Roadshow - MySQL
[PHPUGPH] PHP Roadshow - MySQL
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Retrieving Data From A Database
Retrieving Data From A DatabaseRetrieving Data From A Database
Retrieving Data From A Database
 
MS SQLSERVER:Retrieving Data From A Database
MS SQLSERVER:Retrieving Data From A DatabaseMS SQLSERVER:Retrieving Data From A Database
MS SQLSERVER:Retrieving Data From A Database
 
MS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A DatabaseMS SQL SERVER: Retrieving Data From A Database
MS SQL SERVER: Retrieving Data From A Database
 
sql language
sql languagesql language
sql language
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 

Recently uploaded

SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxjanettecruzeiro1
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceanilsa9823
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricksabhishekparmar618
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130Suhani Kapoor
 
NATA 2024 SYLLABUS, full syllabus explained in detail
NATA 2024 SYLLABUS, full syllabus explained in detailNATA 2024 SYLLABUS, full syllabus explained in detail
NATA 2024 SYLLABUS, full syllabus explained in detailDesigntroIntroducing
 
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service AmravatiVIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Sitegalleryaagency
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)jennyeacort
 
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779Delhi Call girls
 
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 nightCheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 nightDelhi Call girls
 
A level Digipak development Presentation
A level Digipak development PresentationA level Digipak development Presentation
A level Digipak development Presentationamedia6
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...babafaisel
 
ARt app | UX Case Study
ARt app | UX Case StudyARt app | UX Case Study
ARt app | UX Case StudySophia Viganò
 
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`dajasot375
 
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 nightCheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 nightDelhi Call girls
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfAmirYakdi
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptx
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
 
young call girls in Pandav nagar 🔝 9953056974 🔝 Delhi escort Service
young call girls in Pandav nagar 🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Pandav nagar 🔝 9953056974 🔝 Delhi escort Service
young call girls in Pandav nagar 🔝 9953056974 🔝 Delhi escort Service
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricks
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
NATA 2024 SYLLABUS, full syllabus explained in detail
NATA 2024 SYLLABUS, full syllabus explained in detailNATA 2024 SYLLABUS, full syllabus explained in detail
NATA 2024 SYLLABUS, full syllabus explained in detail
 
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
 
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service AmravatiVIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
VIP Call Girl Amravati Aashi 8250192130 Independent Escort Service Amravati
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Site
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
 
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
Best VIP Call Girls Noida Sector 44 Call Me: 8448380779
 
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 nightCheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 night
 
A level Digipak development Presentation
A level Digipak development PresentationA level Digipak development Presentation
A level Digipak development Presentation
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
ARt app | UX Case Study
ARt app | UX Case StudyARt app | UX Case Study
ARt app | UX Case Study
 
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
 
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 nightCheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

lect 2.pptx

  • 1. Database Information Technology Management Dept. Third Stage 2022-2023 Lecture 2 A.Lecturer: Nareen O.Muhamad Email: nareen.mohameed@dpu.edu.krd
  • 2. Objectives  After completing this lesson, you should be able to do the following:  List the capabilities of SQL SELECT statements Execute a basic SELECT statement this include:  Using Arithmetic Expressions  Selecting All OR Specific Column(s).  Defining a Null Value.  Defining a Column Alias  Eliminating Duplicate Rows
  • 3. What is Structured Query Language?  SQL stands for Structured Query Language.  It is the language that is used to extract, manipulate, and structure data that resides in a Relational Database Management System (RDBMS). In other words, to get an answer from your database, you must ask the question in SQL.
  • 4. Model Microsoft SQL Server  Microsoft SQL Server is a relational database language based on the SQL .  Microsoft SQL Server contains two kinds of statements:  Data Definition Language (DDL) statements. These statements let you define and modify the schema of your database.  Data Manipulation Language (DML) statements. These statements let you create, access and modify data in your database.
  • 5. Data Definition Language (DDL) Statement Description CREATE TABLE Defines a table in a database. DROP TABLE Deletes a table from a database. ALTER TABLE Modifies a table in a database. CREATE INDEX Adds an index to a table. DROP INDEX Deletes an index from a table.
  • 6. Data Manipulation Language (DML) Statement Description SELECT Retrieves and displays one or more rows from a table. INSERT INTO Adds new rows to a table. UPDATE Changes column values in one or more rows of a table. DELETE FROM Deletes one or more rows from a table. UNION Combines two or more SELECT statements to create a complex query.
  • 7. Table  In a relational database, all data is organized into tables.  Tables are the database structure that contains the physical data, and they are organized by their columns (or fields) and rows (or records).
  • 8. Creating and Working with tables  Creating employees table and establish primary key constraints. In SQL Server, tables can be created graphically using SQL Server Management Studio (SSMS) or using a query(Learned Later).
  • 9. Capabilities of SQL SELECT statements  A SELECT statement retrieves information from the database. Using a SELECT statement as the following: 1. Projection: choose (few or as many) the columns in a table to returned by a query. 2. Selection: choose the rows in a table to returned by a query. Various criteria used to restrict the rows. 3. Joining: it brings together data that is stored in different tables by creating a link between them (learned later).
  • 10. Basic SELECT Statement 1- Selecting All Columns  SELECT * FROM employees  An asterisk (*) displays all columns of the table  Or all table fields can be written.  SELECT Employe_ID, First_Name, Last_Name, Phone_Number, Address, Salary, Hier_Date, Department_Name FROM employees  It Selects All Columns of All Rows
  • 11. 2-Selecting Specific Columns • SELECT Employe_ID, Last_Name FROM employees • It Selects Specific Columns of All Rows • Columns order can be specified in which you want them to appear in the output, Such that:
  • 12. Arithmetic Expressions  Multiplication and division are evaluated first.  Same priority Operators are evaluated from left to right.  Parentheses are used to force prioritized evaluation and to clarify statements.
  • 13.  SELECT Last_Name, Salary, Salary +300 From employees  The calculated column (SALARY+300) is not a new column in the EMPLOYEES table.  By default, the name of a new column comes from the generation of ( salary+300). Using Arithmetic Expressions
  • 14. Operator Precedence  SELECT last_name,salary, 12*salary+100 From employees The (*) performed before (+).  SELECT last_name,salary, (12*salary)+100 From employees  SELECT last_name,salary, 12*(salary+100) From employees  First to force the expression. Second override the rules of precedence
  • 15. Defining a Null Value  If a row lacks the data value for a particular column, that value is said to be NULL, or to contain a NULL.  A NULL is a value that is unavailable, unassigned, unknown, or inapplicable.  Zero is a number, and a space is a character.  A NULL is not the same as zero or a blank space.  SELECT last_name, Salary, salary, 12*salary FROM employees
  • 16. Null Values - in Arithmetic Expressions  If any column value in an arithmetic expression is NULL, the result is NULL.  Performing division with zero, it gets an error.  Dividing a number by null, the result is a null or unknown.  SELECT last_name, 12*salary*commission_pct FROM employees
  • 17. Defining a Column Alias A column Heading Alias:  Renames a column heading, is useful with calculations.  Immediately follows the column name.  Optional AS keyword used between the column and alias.  Requires double quotation marks if it contains spaces or special characters (# or $). It can be used in both the SELECT and the ORDER BY clause. It cannot be used in the WHERE clause.
  • 18. Using Column Aliases SELECT last_name AS name , Department_Name Dept FROM employees SELECT last_name "Name ", salary*12 "Annual Salary" FROM employees
  • 19. Eliminating Duplicate Rows  The default display of queries is all rows, including duplicate rows.  SELECT department_NameFROM employees  Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause.  SELECT DISTINCT department_Name FROM employees