SlideShare a Scribd company logo
1 of 49
Functions and Joins

Objectives
In this lesson, you will learn to:
 Use functions
 Use different types of joins




Ā©NIIT                                SQL/Lesson 3/Slide 1 of 49
Functions and Joins

3.D.1 Displaying Data in Upper Case Using String
Functions
 A report containing the newspaper name, the name of the
  contact person, and the telephone numbers is required to
  contact various newspapers to place an advertisement. The
  newspaper name should be displayed in uppercase.




Ā©NIIT                                    SQL/Lesson 3/Slide 2 of 49
Functions and Joins

Task List
 Create a format for the query output
 Draft the query
 Execute the query
 Verify that the query output is as per the required results




Ā©NIIT                                         SQL/Lesson 3/Slide 3 of 49
Functions and Joins

Create a format for the query output
 Result:
     The output required in the report is the newspaper name
      (in upper case), the contact person, and the telephone
      number from the Newspaper table
     The column headings in the report are
      cNewspaperName, vContactPerson, and cPhone




Ā©NIIT                                      SQL/Lesson 3/Slide 4 of 49
Functions and Joins

Draft the query
 String Functions: Are used to format data as per specific
  requirements
     Syntax
        SELECT function_name (parameters)
 Result:
     The information is available in the Newspaper table
     The string function to be used to display the names of
      newspapers in uppercase is UPPER
     Therefore, the query using the SELECT statement should
      be:
        SELECT 'Newspaper Name'=UPPER
        (cNewspaperName), vContactPerson, cPhone
        FROM Newspaper
Ā©NIIT                                       SQL/Lesson 3/Slide 5 of 49
Functions and Joins

Execute the query
 Action:
     In the Query Analyzer window, type:
     Execute the query




Ā©NIIT                                       SQL/Lesson 3/Slide 6 of 49
Functions and Joins

Verify that the query output is as per the required
results
 Check whether:
     All the required rows are displayed
     The newspaper names are displayed in upper case




Ā©NIIT                                       SQL/Lesson 3/Slide 7 of 49
Functions and Joins

Just a Minute...
 The names, addresses, and phone numbers of the
  recruitment agencies in Houston are required. However, only
  the first 10 characters of the address should be displayed.




Ā©NIIT                                     SQL/Lesson 3/Slide 8 of 49
Functions and Joins

3.D.2 Adding Days to a Date Using Date Functions
 The proposed deadline for campus recruitment is 10 days from
  the start date of the recruitment process. A report containing
  the college code, the start date for recruitment, and the
  proposed deadline for all colleges the company is visiting
  needs to be displayed.




Ā©NIIT                                      SQL/Lesson 3/Slide 9 of 49
Functions and Joins

Task List
 Create a format for the query output
 Draft the query
 Execute the query
 Verify that the query output is as per the required results




Ā©NIIT                                        SQL/Lesson 3/Slide 10 of 49
Functions and Joins

Create a format for the query output
 Result:
     The output required in the report is the college code, the
      recruitment start date, and the proposed deadline
     The column headings of the report are cCollegeCode,
      dRecruitmentStartDate, and ProposedDeadline, which is
      10 days from the start date




Ā©NIIT                                        SQL/Lesson 3/Slide 11 of 49
Functions and Joins

Draft the query
 Date functions: Are used to manipulate datetime values,
  perform arithmetic operations, and perform date parsing
  (extract components like the day, the month, and the year)
     Syntax
        SELECT date_function (parameters)
 Result:
     The required information is available in the
      CampusRecruitment table
     The date function to be used is DATEADD


Ā©NIIT                                        SQL/Lesson 3/Slide 12 of 49
Functions and Joins

Draft the query (Contd.)
     Therefore, the query using the SELECT statement should
      be:
        SELECT cCollegeCode, dRecruitmentStartDate,
        'Proposed Deadline' = DATEADD(dd, 10,
        dRecruitmentStartDate)
        FROM CampusRecruitment




Ā©NIIT                                     SQL/Lesson 3/Slide 13 of 49
Functions and Joins

Execute the query
 Action:
     In the Query Analyzer window, type the query
     Execute the query




Ā©NIIT                                      SQL/Lesson 3/Slide 14 of 49
Functions and Joins

Verify that the query output is as per the required
results
 Check whether:
     All the required rows are displayed
     The proposed deadline is 10 days from the start date




Ā©NIIT                                       SQL/Lesson 3/Slide 15 of 49
Functions and Joins

Just a Minute...
A schedule for interviews is required. The name of the candidate,
the interviewerā€™s employee code, the date, and the weekday of
the interview are to be printed in alphabetical order of candidate
names in the following format:

   Candidate Name       Interviewer Code   Date         Week Day



   Ā                     Ā                   Ā             Ā 




Ā©NIIT                                          SQL/Lesson 3/Slide 16 of 49
Functions and Joins

3.D.3 Rounding off Values Using Mathematical
Functions
 The test scores of candidates have been declared. Helen
  White has scored 79.9 marks, and she is to be informed of the
  same. Her first name, telephone number, and score have to be
  displayed. The score should be rounded off to the nearest
  integer.




Ā©NIIT                                     SQL/Lesson 3/Slide 17 of 49
Functions and Joins

Task List
 Create a format for the query output
 Draft the query
 Execute the query
 Verify that the query output is as per the required results




Ā©NIIT                                         SQL/Lesson 3/Slide 18 of 49
Functions and Joins

Create a format for the query output
 Result:
     The output required in the report is the first name,
      telephone number, and score of the candidate
     The column headings of the report are vFirstName,
      cPhone, and Score




Ā©NIIT                                         SQL/Lesson 3/Slide 19 of 49
Functions and Joins

Draft the query
 Mathematical Functions: Are used to perform numerical
  operations on mathematical data
     Syntax
        ROUND (numeric_expression, length)
 Result:
     The required information is available in the
      ExternalCandidate table
     The function to be used is ROUND



Ā©NIIT                                        SQL/Lesson 3/Slide 20 of 49
Functions and Joins

Draft the query (Contd.)
     Therefore, the query using the SELECT statement should
      be:
        SELECT vFirstName, cPhone,'Score'=
        ROUND(79.9,0)
        FROM ExternalCandidate
        WHERE vFirstName='Helen'




Ā©NIIT                                     SQL/Lesson 3/Slide 21 of 49
Functions and Joins

Execute the query
 Action:
     In the Query Analyzer window, type:
     Execute the query




Ā©NIIT                                       SQL/Lesson 3/Slide 22 of 49
Functions and Joins

Verify that the query output is as per the required
results
 Check whether the marks are rounded off to the nearest
  numeric value




 Ā©NIIT                                    SQL/Lesson 3/Slide 23 of 49
Functions and Joins

System Functions
 System functions provide a method of querying the system
  tables of SQL Server
     These functions are used to access SQL Server,
      databases, or user-related information
     They enable quick conversion of system and object
      information without writing several queries




Ā©NIIT                                     SQL/Lesson 3/Slide 24 of 49
Functions and Joins

Data Conversion
 The CONVERT function is used to change data from one
  type to another when SQL Server cannot implicitly
  understand a conversion
 Syntax
  CONVERT (datatype [(length)], expression [,
  style])




Ā©NIIT                                   SQL/Lesson 3/Slide 25 of 49
Functions and Joins

Joins
 A join can be defined as an operation that includes the
  retrieval of data from more than one table at a time
 Syntax
  SELECT column_name, column_name [,column_name]
  FROM table_name [CROSS|INNER|[LEFT |
  RIGHT]OUTER] JOIN table_name
  [ON table_name.ref_column_name join_operator
  table_name.ref_column_name]
  [WHERE search_condition]


Ā©NIIT                                       SQL/Lesson 3/Slide 26 of 49
Functions and Joins

Joins (Contd.)
 The various types of joins are:
     Inner Join
     Outer Join
     Cross Join
     Equi Join
     Natural Join
     Self Join




Ā©NIIT                               SQL/Lesson 3/Slide 27 of 49
Functions and Joins

3.D.4 Displaying Data From Two Tables Using Inner
  Joins
 The names of the candidates and their recruitment agencies
  are required for an analysis by senior management. A report
  displaying these details is to be generated.




Ā©NIIT                                     SQL/Lesson 3/Slide 28 of 49
Functions and Joins

Task List
 Create a format for the query output
 Draft the query
 Execute the query
 Verify that the query output is as per the required results




Ā©NIIT                                         SQL/Lesson 3/Slide 29 of 49
Functions and Joins

Create a format for the query output
 Result:
     The required output from the query is a list of candidate
      names and the names of the recruitment agencies that
      sent them




Ā©NIIT                                        SQL/Lesson 3/Slide 30 of 49
Functions and Joins

Draft the query
 Inner Joins
     Syntax
        SELECT column_name, column_name
        [,column_name]
        FROM table_name JOIN table_name
        ON table_name.ref_column_name
        join_operator table_name.ref_column_name
 Cartesian Product: A join that includes more than one table
  without any condition in the ON clause creates a cartesian
  product between the two tables

Ā©NIIT                                      SQL/Lesson 3/Slide 31 of 49
Functions and Joins

Draft the query (Contd.)
 Result:
     The required information is available in the
      ExternalCandidate and RecruitmentAgencies tables
     Therefore, the query using the SELECT statement should
      be:
        SELECT 'Candidate Name' = vFirstName,
        'Recruitment Agency' = cName
        FROM ExternalCandidate JOIN
        RecruitmentAgencies
        ON ExternalCandidate.cAgencyCode =
        RecruitmentAgencies.cAgencyCode
Ā©NIIT                                     SQL/Lesson 3/Slide 32 of 49
Functions and Joins

Execute the query
 Action:
     In the Query Analyzer window, type the query
     Execute the query




Ā©NIIT                                      SQL/Lesson 3/Slide 33 of 49
Functions and Joins

Verify that the query output is as per the required
results
 Check whether:
     The required columns from different tables are displayed
     The required rows are displayed




Ā©NIIT                                       SQL/Lesson 3/Slide 34 of 49
Functions and Joins

Just a Minuteā€¦
 The names of candidates and the newspapers they referred
  for recruitment advertisements are required for an analysis.
  A report displaying these details is to be generated.




Ā©NIIT                                      SQL/Lesson 3/Slide 35 of 49
Functions and Joins

3.D.5 Displaying Data From Two Tables Using Outer
  Joins
 The names of all the external candidates along with the
  names of their recruitment agencies, wherever applicable,
  are required for an analysis. A report displaying these
  details is to be generated.




Ā©NIIT                                      SQL/Lesson 3/Slide 36 of 49
Functions and Joins

Task List
 Create a format for the query output
 Draft the query
 Execute the query
 Verify that the query output is as per the required results




Ā©NIIT                                        SQL/Lesson 3/Slide 37 of 49
Functions and Joins

Create a format for the query output
 Result:
     The required output from the query is the names of all the
      external candidates and their recruitment agencies
      (wherever applicable)




Ā©NIIT                                       SQL/Lesson 3/Slide 38 of 49
Functions and Joins

Draft the query
 Outer Joins
     A join can be termed an outer join when the result set
      contains all rows from one table and the matching rows
      from another
     Syntax
        SELECT column_name, column_name
        [,column_name]
        FROM table_name [LEFT | RIGHT] OUTER JOIN
        table_name
        ON table_name.ref_column_name
        join_operator table_name.ref_column_name
Ā©NIIT                                      SQL/Lesson 3/Slide 39 of 49
Functions and Joins

Draft the query (Contd.)
 Result:
     The required information is available in the
      ExternalCandidate and RecruitmentAgencies tables
     Therefore, the query using the SELECT statement should
      be:
        SELECT vFirstName, vLastName, cName
        FROM ExternalCandidate
        LEFT OUTER JOIN RecruitmentAgencies
        ON ExternalCandidate.cAgencyCode =
        RecruitmentAgencies.cAgencyCode
Ā©NIIT                                     SQL/Lesson 3/Slide 40 of 49
Functions and Joins

Execute the query
 Action:
     In the Query Analyzer window, type:
     Execute the query




Ā©NIIT                                       SQL/Lesson 3/Slide 41 of 49
Functions and Joins

Verify that the query output is as per the required
results
 Action:
     Check whether:
        Ā® The    required columns are displayed
        Ā® All   rows from the first table are displayed
        Ā® The    require rows from the second table are displayed




Ā©NIIT                                           SQL/Lesson 3/Slide 42 of 49
Functions and Joins

Cross Join
 A join that includes more than one table using the keyword
  CROSS is called a cross join.
 Example
  SELECT *
  FROM Titles CROSS JOIN Publishers




Ā©NIIT                                      SQL/Lesson 3/Slide 43 of 49
Functions and Joins

Equi Join
 A join that uses an asterisk (*) sign in the SELECT list and
  displays redundant column data in the result set is termed as
  an equi join
 Example
  SELECT *
  FROM Sales s JOIN Titles t
  ON s.Title_Id = t.Title_Id
  JOIN Publishers p
  ON t.Pub_Id = p.Pub_Id

Ā©NIIT                                      SQL/Lesson 3/Slide 44 of 49
Functions and Joins

Natural Join
 A join that restricts the redundant column data from the
  result set is known as a natural join
 Example
  SELECT t.Title, p.Pub_Name
  FROM Titles t JOIN Publishers p
  ON t.Pub_Id = p.Pub_Id




Ā©NIIT                                       SQL/Lesson 3/Slide 45 of 49
Functions and Joins

Self Join
 A join is said to be a self join when one row in a table
  correlates with other rows in the same table
 Example
  SELECT t1.title,t2.title , t1.price
  FROM   titles   t1             JOIN      titles           t2        ON
  t1.price=t2.price
  WHERE t1.price=2.99




Ā©NIIT                                         SQL/Lesson 3/Slide 46 of 49
Functions and Joins

Summary
In this lesson you learned that:
 SQL Server uses string functions, which can be used as part
   of any character expression.
 SQL Server includes date functions for performing date
   parsing and date arithmetic.
 The CONVERT function is used to change data from one
   type to another when SQL Server cannot implicitly
   understand a conversion.
 SQL Server provides a method of retrieving data from more
   than one table using joins.



Ā©NIIT                                     SQL/Lesson 3/Slide 47 of 49
Functions and Joins

Summary (Contd.)
 In inner join, data from multiple tables is displayed after
  comparing values present in a common column. Only rows
  with values satisfying the join condition in the common
  column are displayed.
 A join can be termed an outer join when the result set
  contains all rows from one table and the matching rows from
  another.
 A join that includes more than one table using the keyword
  CROSS is called a cross join.
 A join that uses an asterisk (*) sign in the SELECT list and
  displays redundant column data in the result set is termed as
  an equi join.

Ā©NIIT                                       SQL/Lesson 3/Slide 48 of 49
Functions and Joins

Summary (Contd.)
 A join that restricts the redundant column data from the
  result set is known as a natural join.
 A join is said to be a self join when one row in a table
  correlates with other rows in the same table.




Ā©NIIT                                         SQL/Lesson 3/Slide 49 of 49

More Related Content

What's hot

Practical index dms 22319
Practical index dms 22319Practical index dms 22319
Practical index dms 22319ARVIND SARDAR
Ā 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comkopiko33
Ā 
BIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comBIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comagathachristie179
Ā 
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 BIS 245 OUTLET Inspiring Innovation--bis245outlet.com BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
BIS 245 OUTLET Inspiring Innovation--bis245outlet.comwilliamwordsworth45
Ā 
BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comagathachristie291
Ā 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comthomashard72
Ā 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comagathachristie241
Ā 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comKeatonJennings120
Ā 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comagathachristie256
Ā 
Management productivity tools1
Management productivity tools1Management productivity tools1
Management productivity tools1Hari Krishnan
Ā 
CIS 336 STUDY Education Planning--cis336study.com
CIS 336 STUDY Education Planning--cis336study.comCIS 336 STUDY Education Planning--cis336study.com
CIS 336 STUDY Education Planning--cis336study.comagathachristie299
Ā 
Part1 (2 Examene)
Part1 (2 Examene)Part1 (2 Examene)
Part1 (2 Examene)guestcf14bd2
Ā 
Part2 (1 Examen)
Part2 (1 Examen)Part2 (1 Examen)
Part2 (1 Examen)guestcf14bd2
Ā 
Tutorial 3 Working with Formulas and Functions
Tutorial 3 Working with Formulas and FunctionsTutorial 3 Working with Formulas and Functions
Tutorial 3 Working with Formulas and Functionscios135
Ā 
CIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.comCIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.comWindyMiller44
Ā 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical listRajSingh734307
Ā 
Tutorial 10: Performing What-IF Analyses
Tutorial 10: Performing What-IF AnalysesTutorial 10: Performing What-IF Analyses
Tutorial 10: Performing What-IF Analysescios135
Ā 
Tutorial 8: Developing an Excel Application
Tutorial 8: Developing an Excel ApplicationTutorial 8: Developing an Excel Application
Tutorial 8: Developing an Excel Applicationcios135
Ā 
Tutorial 7: Advanced Functions and Conitional Formating
Tutorial 7: Advanced Functions and Conitional FormatingTutorial 7: Advanced Functions and Conitional Formating
Tutorial 7: Advanced Functions and Conitional Formatingcios135
Ā 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3Gurpreet singh
Ā 

What's hot (20)

Practical index dms 22319
Practical index dms 22319Practical index dms 22319
Practical index dms 22319
Ā 
BIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.comBIS 245 Lessons in Excellence / bis245.com
BIS 245 Lessons in Excellence / bis245.com
Ā 
BIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.comBIS 245 OUTLET Achievement Education--bis245outlet.com
BIS 245 OUTLET Achievement Education--bis245outlet.com
Ā 
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
 BIS 245 OUTLET Inspiring Innovation--bis245outlet.com BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
BIS 245 OUTLET Inspiring Innovation--bis245outlet.com
Ā 
BIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.comBIS 245 OUTLET Introduction Education--bis245outlet.com
BIS 245 OUTLET Introduction Education--bis245outlet.com
Ā 
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.comBIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
BIS 245 HOMEWORK Lessons in Excellence--bis245homework.com
Ā 
BIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.comBIS 245 HOMEWORK Redefined Education--bis245homework.com
BIS 245 HOMEWORK Redefined Education--bis245homework.com
Ā 
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.comBIS 245 HOMEWORK Become Exceptional--bis245homework.com
BIS 245 HOMEWORK Become Exceptional--bis245homework.com
Ā 
BIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.comBIS 245 HOMEWORK Introduction Education--bis245homework.com
BIS 245 HOMEWORK Introduction Education--bis245homework.com
Ā 
Management productivity tools1
Management productivity tools1Management productivity tools1
Management productivity tools1
Ā 
CIS 336 STUDY Education Planning--cis336study.com
CIS 336 STUDY Education Planning--cis336study.comCIS 336 STUDY Education Planning--cis336study.com
CIS 336 STUDY Education Planning--cis336study.com
Ā 
Part1 (2 Examene)
Part1 (2 Examene)Part1 (2 Examene)
Part1 (2 Examene)
Ā 
Part2 (1 Examen)
Part2 (1 Examen)Part2 (1 Examen)
Part2 (1 Examen)
Ā 
Tutorial 3 Working with Formulas and Functions
Tutorial 3 Working with Formulas and FunctionsTutorial 3 Working with Formulas and Functions
Tutorial 3 Working with Formulas and Functions
Ā 
CIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.comCIS 336 Education Planning--cis336.com
CIS 336 Education Planning--cis336.com
Ā 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
Ā 
Tutorial 10: Performing What-IF Analyses
Tutorial 10: Performing What-IF AnalysesTutorial 10: Performing What-IF Analyses
Tutorial 10: Performing What-IF Analyses
Ā 
Tutorial 8: Developing an Excel Application
Tutorial 8: Developing an Excel ApplicationTutorial 8: Developing an Excel Application
Tutorial 8: Developing an Excel Application
Ā 
Tutorial 7: Advanced Functions and Conitional Formating
Tutorial 7: Advanced Functions and Conitional FormatingTutorial 7: Advanced Functions and Conitional Formating
Tutorial 7: Advanced Functions and Conitional Formating
Ā 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
Ā 

Similar to Sql xp 03

FP304 DATABASE SYSTEM FINAL PAPER
FP304    DATABASE SYSTEM FINAL PAPERFP304    DATABASE SYSTEM FINAL PAPER
FP304 DATABASE SYSTEM FINAL PAPERSyahriha Ruslan
Ā 
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)Hany Paulina
Ā 
75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docx75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docxsleeperharwell
Ā 
Structure
StructureStructure
StructureALI RAZA
Ā 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptManivannan837728
Ā 
ASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEAR
ASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEARASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEAR
ASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEARDon Dooley
Ā 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
Ā 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
Ā 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
Ā 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxravi2692kumar
Ā 
Assignment booklet 2019 dit 3 years (3rd year)
Assignment booklet 2019 dit 3 years (3rd year)Assignment booklet 2019 dit 3 years (3rd year)
Assignment booklet 2019 dit 3 years (3rd year)RekilweKgaditsi
Ā 
Ijcatr04071001
Ijcatr04071001Ijcatr04071001
Ijcatr04071001Editor IJCATR
Ā 
Development of Web-based Job Fair Information System
Development of Web-based Job Fair Information SystemDevelopment of Web-based Job Fair Information System
Development of Web-based Job Fair Information SystemEditor IJCATR
Ā 
Development of Web-based Job Fair Information System
Development of Web-based Job Fair Information SystemDevelopment of Web-based Job Fair Information System
Development of Web-based Job Fair Information SystemEditor IJCATR
Ā 
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...Alpro
Ā 
CIS 505 Effective Communication - snaptutorial.com
CIS 505 Effective Communication - snaptutorial.comCIS 505 Effective Communication - snaptutorial.com
CIS 505 Effective Communication - snaptutorial.comdonaldzs2
Ā 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxVigneshkumar Ponnusamy
Ā 
27 pso business_requirements
27 pso business_requirements27 pso business_requirements
27 pso business_requirementsMarcelo Mesti
Ā 
C programming session 13
C programming session 13C programming session 13
C programming session 13Vivek Singh
Ā 

Similar to Sql xp 03 (20)

FP304 DATABASE SYSTEM FINAL PAPER
FP304    DATABASE SYSTEM FINAL PAPERFP304    DATABASE SYSTEM FINAL PAPER
FP304 DATABASE SYSTEM FINAL PAPER
Ā 
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ā 
75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docx75629 Topic prevention measures for vulneranbilitiesNumber of.docx
75629 Topic prevention measures for vulneranbilitiesNumber of.docx
Ā 
Structure
StructureStructure
Structure
Ā 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
Ā 
ASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEAR
ASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEARASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEAR
ASSIGNMENT BOOKLET 2018 DIPLOMA IN IT 3 YEARS 1ST YEAR
Ā 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016
Ā 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016
Ā 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016
Ā 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptx
Ā 
Assignment booklet 2019 dit 3 years (3rd year)
Assignment booklet 2019 dit 3 years (3rd year)Assignment booklet 2019 dit 3 years (3rd year)
Assignment booklet 2019 dit 3 years (3rd year)
Ā 
Ijcatr04071001
Ijcatr04071001Ijcatr04071001
Ijcatr04071001
Ā 
Development of Web-based Job Fair Information System
Development of Web-based Job Fair Information SystemDevelopment of Web-based Job Fair Information System
Development of Web-based Job Fair Information System
Ā 
Development of Web-based Job Fair Information System
Development of Web-based Job Fair Information SystemDevelopment of Web-based Job Fair Information System
Development of Web-based Job Fair Information System
Ā 
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Ā 
CIS 505 Effective Communication - snaptutorial.com
CIS 505 Effective Communication - snaptutorial.comCIS 505 Effective Communication - snaptutorial.com
CIS 505 Effective Communication - snaptutorial.com
Ā 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
Ā 
Fahri tugas cloud1
Fahri tugas cloud1Fahri tugas cloud1
Fahri tugas cloud1
Ā 
27 pso business_requirements
27 pso business_requirements27 pso business_requirements
27 pso business_requirements
Ā 
C programming session 13
C programming session 13C programming session 13
C programming session 13
Ā 

More from Niit Care

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 bNiit Care
Ā 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 bNiit Care
Ā 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 aNiit Care
Ā 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 cNiit Care
Ā 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 bNiit Care
Ā 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 aNiit Care
Ā 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 cNiit Care
Ā 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 bNiit Care
Ā 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 aNiit Care
Ā 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 cNiit Care
Ā 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 aNiit Care
Ā 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 cNiit Care
Ā 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-cNiit Care
Ā 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-bNiit Care
Ā 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-aNiit Care
Ā 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-cNiit Care
Ā 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-bNiit Care
Ā 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-aNiit Care
Ā 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 bNiit Care
Ā 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 cNiit Care
Ā 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
Ā 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
Ā 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
Ā 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
Ā 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
Ā 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
Ā 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
Ā 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
Ā 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
Ā 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
Ā 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
Ā 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
Ā 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
Ā 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
Ā 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
Ā 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
Ā 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
Ā 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
Ā 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
Ā 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
Ā 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
Ā 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĆŗjo
Ā 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
Ā 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
Ā 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜RTylerCroy
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
Ā 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
Ā 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
Ā 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
Ā 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Ā 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Ā 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
Ā 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Ā 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Ā 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 

Sql xp 03

  • 1. Functions and Joins Objectives In this lesson, you will learn to: Use functions Use different types of joins Ā©NIIT SQL/Lesson 3/Slide 1 of 49
  • 2. Functions and Joins 3.D.1 Displaying Data in Upper Case Using String Functions A report containing the newspaper name, the name of the contact person, and the telephone numbers is required to contact various newspapers to place an advertisement. The newspaper name should be displayed in uppercase. Ā©NIIT SQL/Lesson 3/Slide 2 of 49
  • 3. Functions and Joins Task List Create a format for the query output Draft the query Execute the query Verify that the query output is as per the required results Ā©NIIT SQL/Lesson 3/Slide 3 of 49
  • 4. Functions and Joins Create a format for the query output Result: The output required in the report is the newspaper name (in upper case), the contact person, and the telephone number from the Newspaper table The column headings in the report are cNewspaperName, vContactPerson, and cPhone Ā©NIIT SQL/Lesson 3/Slide 4 of 49
  • 5. Functions and Joins Draft the query String Functions: Are used to format data as per specific requirements Syntax SELECT function_name (parameters) Result: The information is available in the Newspaper table The string function to be used to display the names of newspapers in uppercase is UPPER Therefore, the query using the SELECT statement should be: SELECT 'Newspaper Name'=UPPER (cNewspaperName), vContactPerson, cPhone FROM Newspaper Ā©NIIT SQL/Lesson 3/Slide 5 of 49
  • 6. Functions and Joins Execute the query Action: In the Query Analyzer window, type: Execute the query Ā©NIIT SQL/Lesson 3/Slide 6 of 49
  • 7. Functions and Joins Verify that the query output is as per the required results Check whether: All the required rows are displayed The newspaper names are displayed in upper case Ā©NIIT SQL/Lesson 3/Slide 7 of 49
  • 8. Functions and Joins Just a Minute... The names, addresses, and phone numbers of the recruitment agencies in Houston are required. However, only the first 10 characters of the address should be displayed. Ā©NIIT SQL/Lesson 3/Slide 8 of 49
  • 9. Functions and Joins 3.D.2 Adding Days to a Date Using Date Functions The proposed deadline for campus recruitment is 10 days from the start date of the recruitment process. A report containing the college code, the start date for recruitment, and the proposed deadline for all colleges the company is visiting needs to be displayed. Ā©NIIT SQL/Lesson 3/Slide 9 of 49
  • 10. Functions and Joins Task List Create a format for the query output Draft the query Execute the query Verify that the query output is as per the required results Ā©NIIT SQL/Lesson 3/Slide 10 of 49
  • 11. Functions and Joins Create a format for the query output Result: The output required in the report is the college code, the recruitment start date, and the proposed deadline The column headings of the report are cCollegeCode, dRecruitmentStartDate, and ProposedDeadline, which is 10 days from the start date Ā©NIIT SQL/Lesson 3/Slide 11 of 49
  • 12. Functions and Joins Draft the query Date functions: Are used to manipulate datetime values, perform arithmetic operations, and perform date parsing (extract components like the day, the month, and the year) Syntax SELECT date_function (parameters) Result: The required information is available in the CampusRecruitment table The date function to be used is DATEADD Ā©NIIT SQL/Lesson 3/Slide 12 of 49
  • 13. Functions and Joins Draft the query (Contd.) Therefore, the query using the SELECT statement should be: SELECT cCollegeCode, dRecruitmentStartDate, 'Proposed Deadline' = DATEADD(dd, 10, dRecruitmentStartDate) FROM CampusRecruitment Ā©NIIT SQL/Lesson 3/Slide 13 of 49
  • 14. Functions and Joins Execute the query Action: In the Query Analyzer window, type the query Execute the query Ā©NIIT SQL/Lesson 3/Slide 14 of 49
  • 15. Functions and Joins Verify that the query output is as per the required results Check whether: All the required rows are displayed The proposed deadline is 10 days from the start date Ā©NIIT SQL/Lesson 3/Slide 15 of 49
  • 16. Functions and Joins Just a Minute... A schedule for interviews is required. The name of the candidate, the interviewerā€™s employee code, the date, and the weekday of the interview are to be printed in alphabetical order of candidate names in the following format: Candidate Name Interviewer Code Date Week Day Ā  Ā  Ā  Ā  Ā©NIIT SQL/Lesson 3/Slide 16 of 49
  • 17. Functions and Joins 3.D.3 Rounding off Values Using Mathematical Functions The test scores of candidates have been declared. Helen White has scored 79.9 marks, and she is to be informed of the same. Her first name, telephone number, and score have to be displayed. The score should be rounded off to the nearest integer. Ā©NIIT SQL/Lesson 3/Slide 17 of 49
  • 18. Functions and Joins Task List Create a format for the query output Draft the query Execute the query Verify that the query output is as per the required results Ā©NIIT SQL/Lesson 3/Slide 18 of 49
  • 19. Functions and Joins Create a format for the query output Result: The output required in the report is the first name, telephone number, and score of the candidate The column headings of the report are vFirstName, cPhone, and Score Ā©NIIT SQL/Lesson 3/Slide 19 of 49
  • 20. Functions and Joins Draft the query Mathematical Functions: Are used to perform numerical operations on mathematical data Syntax ROUND (numeric_expression, length) Result: The required information is available in the ExternalCandidate table The function to be used is ROUND Ā©NIIT SQL/Lesson 3/Slide 20 of 49
  • 21. Functions and Joins Draft the query (Contd.) Therefore, the query using the SELECT statement should be: SELECT vFirstName, cPhone,'Score'= ROUND(79.9,0) FROM ExternalCandidate WHERE vFirstName='Helen' Ā©NIIT SQL/Lesson 3/Slide 21 of 49
  • 22. Functions and Joins Execute the query Action: In the Query Analyzer window, type: Execute the query Ā©NIIT SQL/Lesson 3/Slide 22 of 49
  • 23. Functions and Joins Verify that the query output is as per the required results Check whether the marks are rounded off to the nearest numeric value Ā©NIIT SQL/Lesson 3/Slide 23 of 49
  • 24. Functions and Joins System Functions System functions provide a method of querying the system tables of SQL Server These functions are used to access SQL Server, databases, or user-related information They enable quick conversion of system and object information without writing several queries Ā©NIIT SQL/Lesson 3/Slide 24 of 49
  • 25. Functions and Joins Data Conversion The CONVERT function is used to change data from one type to another when SQL Server cannot implicitly understand a conversion Syntax CONVERT (datatype [(length)], expression [, style]) Ā©NIIT SQL/Lesson 3/Slide 25 of 49
  • 26. Functions and Joins Joins A join can be defined as an operation that includes the retrieval of data from more than one table at a time Syntax SELECT column_name, column_name [,column_name] FROM table_name [CROSS|INNER|[LEFT | RIGHT]OUTER] JOIN table_name [ON table_name.ref_column_name join_operator table_name.ref_column_name] [WHERE search_condition] Ā©NIIT SQL/Lesson 3/Slide 26 of 49
  • 27. Functions and Joins Joins (Contd.) The various types of joins are: Inner Join Outer Join Cross Join Equi Join Natural Join Self Join Ā©NIIT SQL/Lesson 3/Slide 27 of 49
  • 28. Functions and Joins 3.D.4 Displaying Data From Two Tables Using Inner Joins The names of the candidates and their recruitment agencies are required for an analysis by senior management. A report displaying these details is to be generated. Ā©NIIT SQL/Lesson 3/Slide 28 of 49
  • 29. Functions and Joins Task List Create a format for the query output Draft the query Execute the query Verify that the query output is as per the required results Ā©NIIT SQL/Lesson 3/Slide 29 of 49
  • 30. Functions and Joins Create a format for the query output Result: The required output from the query is a list of candidate names and the names of the recruitment agencies that sent them Ā©NIIT SQL/Lesson 3/Slide 30 of 49
  • 31. Functions and Joins Draft the query Inner Joins Syntax SELECT column_name, column_name [,column_name] FROM table_name JOIN table_name ON table_name.ref_column_name join_operator table_name.ref_column_name Cartesian Product: A join that includes more than one table without any condition in the ON clause creates a cartesian product between the two tables Ā©NIIT SQL/Lesson 3/Slide 31 of 49
  • 32. Functions and Joins Draft the query (Contd.) Result: The required information is available in the ExternalCandidate and RecruitmentAgencies tables Therefore, the query using the SELECT statement should be: SELECT 'Candidate Name' = vFirstName, 'Recruitment Agency' = cName FROM ExternalCandidate JOIN RecruitmentAgencies ON ExternalCandidate.cAgencyCode = RecruitmentAgencies.cAgencyCode Ā©NIIT SQL/Lesson 3/Slide 32 of 49
  • 33. Functions and Joins Execute the query Action: In the Query Analyzer window, type the query Execute the query Ā©NIIT SQL/Lesson 3/Slide 33 of 49
  • 34. Functions and Joins Verify that the query output is as per the required results Check whether: The required columns from different tables are displayed The required rows are displayed Ā©NIIT SQL/Lesson 3/Slide 34 of 49
  • 35. Functions and Joins Just a Minuteā€¦ The names of candidates and the newspapers they referred for recruitment advertisements are required for an analysis. A report displaying these details is to be generated. Ā©NIIT SQL/Lesson 3/Slide 35 of 49
  • 36. Functions and Joins 3.D.5 Displaying Data From Two Tables Using Outer Joins The names of all the external candidates along with the names of their recruitment agencies, wherever applicable, are required for an analysis. A report displaying these details is to be generated. Ā©NIIT SQL/Lesson 3/Slide 36 of 49
  • 37. Functions and Joins Task List Create a format for the query output Draft the query Execute the query Verify that the query output is as per the required results Ā©NIIT SQL/Lesson 3/Slide 37 of 49
  • 38. Functions and Joins Create a format for the query output Result: The required output from the query is the names of all the external candidates and their recruitment agencies (wherever applicable) Ā©NIIT SQL/Lesson 3/Slide 38 of 49
  • 39. Functions and Joins Draft the query Outer Joins A join can be termed an outer join when the result set contains all rows from one table and the matching rows from another Syntax SELECT column_name, column_name [,column_name] FROM table_name [LEFT | RIGHT] OUTER JOIN table_name ON table_name.ref_column_name join_operator table_name.ref_column_name Ā©NIIT SQL/Lesson 3/Slide 39 of 49
  • 40. Functions and Joins Draft the query (Contd.) Result: The required information is available in the ExternalCandidate and RecruitmentAgencies tables Therefore, the query using the SELECT statement should be: SELECT vFirstName, vLastName, cName FROM ExternalCandidate LEFT OUTER JOIN RecruitmentAgencies ON ExternalCandidate.cAgencyCode = RecruitmentAgencies.cAgencyCode Ā©NIIT SQL/Lesson 3/Slide 40 of 49
  • 41. Functions and Joins Execute the query Action: In the Query Analyzer window, type: Execute the query Ā©NIIT SQL/Lesson 3/Slide 41 of 49
  • 42. Functions and Joins Verify that the query output is as per the required results Action: Check whether: Ā® The required columns are displayed Ā® All rows from the first table are displayed Ā® The require rows from the second table are displayed Ā©NIIT SQL/Lesson 3/Slide 42 of 49
  • 43. Functions and Joins Cross Join A join that includes more than one table using the keyword CROSS is called a cross join. Example SELECT * FROM Titles CROSS JOIN Publishers Ā©NIIT SQL/Lesson 3/Slide 43 of 49
  • 44. Functions and Joins Equi Join A join that uses an asterisk (*) sign in the SELECT list and displays redundant column data in the result set is termed as an equi join Example SELECT * FROM Sales s JOIN Titles t ON s.Title_Id = t.Title_Id JOIN Publishers p ON t.Pub_Id = p.Pub_Id Ā©NIIT SQL/Lesson 3/Slide 44 of 49
  • 45. Functions and Joins Natural Join A join that restricts the redundant column data from the result set is known as a natural join Example SELECT t.Title, p.Pub_Name FROM Titles t JOIN Publishers p ON t.Pub_Id = p.Pub_Id Ā©NIIT SQL/Lesson 3/Slide 45 of 49
  • 46. Functions and Joins Self Join A join is said to be a self join when one row in a table correlates with other rows in the same table Example SELECT t1.title,t2.title , t1.price FROM titles t1 JOIN titles t2 ON t1.price=t2.price WHERE t1.price=2.99 Ā©NIIT SQL/Lesson 3/Slide 46 of 49
  • 47. Functions and Joins Summary In this lesson you learned that: SQL Server uses string functions, which can be used as part of any character expression. SQL Server includes date functions for performing date parsing and date arithmetic. The CONVERT function is used to change data from one type to another when SQL Server cannot implicitly understand a conversion. SQL Server provides a method of retrieving data from more than one table using joins. Ā©NIIT SQL/Lesson 3/Slide 47 of 49
  • 48. Functions and Joins Summary (Contd.) In inner join, data from multiple tables is displayed after comparing values present in a common column. Only rows with values satisfying the join condition in the common column are displayed. A join can be termed an outer join when the result set contains all rows from one table and the matching rows from another. A join that includes more than one table using the keyword CROSS is called a cross join. A join that uses an asterisk (*) sign in the SELECT list and displays redundant column data in the result set is termed as an equi join. Ā©NIIT SQL/Lesson 3/Slide 48 of 49
  • 49. Functions and Joins Summary (Contd.) A join that restricts the redundant column data from the result set is known as a natural join. A join is said to be a self join when one row in a table correlates with other rows in the same table. Ā©NIIT SQL/Lesson 3/Slide 49 of 49