0% found this document useful (0 votes)
51 views15 pages

TR04 - Retrieve Data PDF

This document provides an agenda for an advanced SQL Server training session that lasts 1 hour. The agenda covers retrieving data using SQL SELECT statements, DISTINCT clauses, WHERE clauses, AND/OR clauses, IN clauses, BETWEEN clauses, LIKE clauses, ORDER BY clauses, GROUP BY clauses, and COUNT clauses. Examples are provided for each. The document concludes by recommending additional learning resources like Microsoft Virtual Academy, practice in Microsoft Virtual Labs, and the TechNet forum.

Uploaded by

Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views15 pages

TR04 - Retrieve Data PDF

This document provides an agenda for an advanced SQL Server training session that lasts 1 hour. The agenda covers retrieving data using SQL SELECT statements, DISTINCT clauses, WHERE clauses, AND/OR clauses, IN clauses, BETWEEN clauses, LIKE clauses, ORDER BY clauses, GROUP BY clauses, and COUNT clauses. Examples are provided for each. The document concludes by recommending additional learning resources like Microsoft Virtual Academy, practice in Microsoft Virtual Labs, and the TechNet forum.

Uploaded by

Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Welcome to SQL Server Training

( Advanced Training - 30 Hours)

Karthikeyan | Technical Consultant


[email protected] | +91 9790768919
SQL Server Advanced Training
Session Duration : 1 Hour
Agenda
• Day 5 - Retrieve Data • Day 5 - Retrieve Data

• SQL SELECT Statement • SQL BETWEEN Clause

• SQL DISTINCT Clause • SQL LIKE Clause

• SQL WHERE Clause • SQL ORDER BY Clause

• SQL AND / OR Clause • SQL GROUP BY Clause

• SQL IN Clause • SQL COUNT Clause


Day 5 - Retrieve Data
SQL SELECT Statement
• Retrieve all values in selected object.

Note:
*  Means will fetch all column names or Field Names.

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME>

Example:
SELECT Sno, Name, Age, DOJ from Student
SELECT * from Student
SQL DISTINCT Clause
• Eliminate duplicate values in the selected object.

Syntax:
SELECT DISTINCT Column1, Column2, Column3, .. ColumnN from <TABLE NAME>

Example:
SELECT DISTINCT Sno, Name, Age, DOJ from Student
SELECT DISTINCT * from Student
SQL WHERE Clause
• Fetch the information with specific condition.

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE <CONDITION>

Example:
SELECT Sno, Name, Age, DOJ from Student WHERE Sno = 1
SELECT * from Student WHERE Name = ‘Senthil’
SQL AND/OR Clause
• AND - Check both conditions true.
• OR - Check any one condition true.

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE
<CONDITION1> <AND / OR > <CONDITION2>

Example:
SELECT Sno, Name, Age, DOJ from Student WHERE Sno = 1 AND Name = ‘Senthil’
SELECT * from Student WHERE Name like ‘Senth%’ or Sno = 1
SQL IN Clause
• IN - Check within conditions.

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE
<COLUMNNAME> IN (<VAL1>, <VAL2>, <VAL3>,…. <VALN>)

Example:
SELECT Sno, Name, Age, DOJ from Student WHERE Sno in (1,4)
SELECT * from Student WHERE Name in (‘Senthil’,’Kumar’)
SQL BETWEEN Clause
• Between - Values between the range

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE
<COLUMNNAME> BETWEEN (<VAL1> AND <VAL2>)

Example:
SELECT Sno, Name, Age, DOJ from Student WHERE Sno in (1,4)
SELECT * from Student WHERE Name in (‘Senthil’,’Kumar’)
SQL LIKE Clause
• LIKE - Refer the same pattern

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE
<COLUMNNAME> LIKE (<PATTERN>)

Example:
SELECT * from Student WHERE Name Like ‘Senthil%’
SELECT * from Student WHERE Name Like ‘%il’
SELECT * from Student WHERE Name Like ‘S%il’
SQL ORDER BY Clause
• ORDER BY - Retrieve the values are in ascending or descending order.

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE <CONDITION>
ORDER BY <COLUMNNAME> [ASC / DESC]

Example:
SELECT * from Student WHERE Name Like ‘Senthil%’ ORDER BY Name Asc
SELECT * from Student WHERE Name Like ‘%il’ ORDER BY Name Desc
SELECT * from Student WHERE Name Like ‘S%il’ ORDER BY 3
SQL GROUP BY Clause
• GROUP BY – Group by particular column.

Syntax:
SELECT Column1, Column2, Column3, .. ColumnN from <TABLE NAME> WHERE <CONDITION>
GROUP BY <COLUMNNAME>

Example:
SELECT * from Student WHERE Name Like ‘Senthil%’ GROUP BY Name
SELECT * from Student WHERE Name Like ‘%il’ GROUP BY Name
SQL COUNT Clause
• COUNT - No of counts.

Syntax:
SELECT COUNT(<COLUMNNAME>) from <TABLE NAME> [WHERE <CONDITION>]

Example:
SELECT COUNT(Name) from Student WHERE Name Like ‘Senthil%’
SELECT COUNT(Name) from Student
LAB Demo
To Learn SQL Server you have use it more
Here are Some reference Links :

To Learn More : Use Microsoft Virtual Academy

Thank You For Practice : Use Microsoft Virtual Labs


For Forum: Use TechNet

Karthikeyan | Technical Consultant


[email protected] | +91 9790768919

You might also like