SQL Task Presentation: Naveen J

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

SQL Task

presentation
Naveen J
Business problem
To create a database for attendance portal of a organisation and to perform
exercise on the Sql topics given for that the following table are included

● Attendance table
● Employee detail
● Permission detail
● Leave detail
● Department detail
Topics
● Keys
● Joins
● Subqueries
● String functions
● Datetime functions
● Stored procedures
Keys
Keys in sql are the set of attributes that is used to specify the particular
column in a table and to find or to create a relation between the tables in a
database in this task I have used keys are as follows

Primary Key

Foriegn Key

Unique key
joins
Joins are used to retrieve data from different tables by combining the two or
more tables with the help of relation between the tables. There are different
types of joins used in sql.

● Inner join
● Right Join
● Left Join
● Outer join
Example
To find the employee who are taken leave or
permission in two days and the status of the
request.

In this query right join retrieve the common data


on request_id and all data on permission_detail.

Then left join fetch the common data on ld.req_id


and all data left table and union combine all the
data from both query
Example
The employee applied both
permission and leave on two days
and status of the request

In this query combine


emp_detail,leave_detail and
permission_detail by inner join it
returns only common rows between
the tables
Subqueries
A subquery is a another sql query that present inside the query. The result of
the subquery is used in the main query to obtain result.there are different
types of subqueries

● Scalar subquery
● Multiple row subquery
Example

First query is to find the employee detail who has the


salary more than the average salary this query is a
example for scalar subquery.

Second is to fetch the employee detail who joined the


company before the manager kavitha this query is ex
for nested query and multiple row subquery.
String functions
String functions in Sql are used to manipulate the string datas in the table .

There are many String functions in SQL from that i have used

Lower,Upper,concat,reverse and substring


Example
First query to return the first_name
and last_name are combined as full
name in separate column

Second query return first_name in


lower case and reversed then
last_name first two letters in
uppercase inside the braces
Datetime functions
Datetime in Sql used to manipulate date time data present in the table by
changing the date time format,extract particular parameter on the date time
column and calculate the difference between two date time datas

Curdate,datediff,day name,month name and timediff are some date time


functions used
Example
To calculate the employee
age,experience with the company
and day of joining , month of joining
Procedures
stored procedure is a set of statements that perform some defined actions.
We make stored procedures so that we can reuse statements that are used
frequently.

● Without parameter
● With parameter

You might also like