With the help of following example we will try to understand the following topic.We will consider the following schema to cover the whole topic so let's start:
To understand the following example we will divide this into following parts and try to solve it one by one so lets see how we can solve this schema.
Part 01
select MONTH(enter_date) from Works_on_Table GROUP by MONTH(enter_date);
select * from Works_on_Table
Part 02
select COUNT(emp_no),[Department Table].location from [Employee Table] JOIN [Department Table] ON [Employee Table].dept_mo=[Department
Table].dept_id GROUP BY location HAVING COUNT(emp_no)>0;
select * from [Employee Table]
select * from [Department Table]
Part 03
select COUNT(emp_no),[Department Table].location from [Employee Table] JOIN [Department Table] ON [Employee Table].dept_mo=[Department
Table].dept_id GROUP BY location HAVING COUNT(emp_no)>0;
select * from [Employee Table]
select * from [Department Table]
Part 04
SELECT [Project Table].project_no,[Project Table].project_name FROM [Project Table] LEFT OUTER JOIN
Works_on_Table ON [Project
Table].project_no=Works_on_Table.project_no
EXCEPT
SELECT Works_on_Table.project_no,[Project Table].project_name FROM [Project Table] RIGHT OUTER JOIN
Works_on_Table ON [Project
Table].project_no=Works_on_Table.project_no;
select * from Works_on_Table
select * from [Project Table]
Part 05
SELECT [Employee Table].emp_no,Works_on_Table.project_no FROM [Employee Table] LEFT OUTER JOIN
Works_on_Table ON [Employee
Table].emp_no=Works_on_Table.emp_no
select * from Works_on_Table
select * from [Employee Table]
Part 06
SELECT customer_tbl.Customer, ages_tbl.AgeGroup FROM
ages_tbl JOIN customer_tbl ON DATEDIFF(year,customer_tbl.DOB,getDate())<=ages_tbl.AgeMax AND DATEDIFF(year,customer_tbl.DOB,getDate())>=ages_tbl.AgeMin
There are two types:
2. Procedures can have input/output parameters for it whereas functions can have only input parameters.
3. Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
4. Functions can be called from procedure whereas procedures cannot be called from function.
Q4: Write a query to retrieve a particular Invoice for Customer “101” and order number “A221219” 5 C. Create a trigger that updates the stock as soon as an order is successfully completed (i.e. payment received and product(s) shipped to customer).
Ans:
No comments:
Post a Comment