Tuesday 1 March 2016

NIIT  SQL LAB@HOME 3

1.Display all the territories whose name begin with 'N'.

ANSWER: Select *
                   From Sales.SalesTerritory
                   Where Name like 'N%'

2.Display the detail of those stores that have Bike in their name.

ANSWER: Select *
                   From Sales.Store
                   Where Name like '%Bike%'

3.Display the Salesperson Id, TerritoryID and Sales Quota for those sales persons who have been assigned a sales quota.

ANSWER: Select 'SalesPersonId' = SalesPersonID, 'TerritoryId' = Territory ID, 'Sales Quota' = Sales Quota
From Sales.SalesPerson
Where Sales Quota IS NOT NULL

4.Display the top three sales person based on bonus.

ANSWER: Select top 3*
                   From Sales.SalesPerson
                   Order by Bonus desc

5.Display a report that contains the employee ID, login ID, and the title of employees.The report should display the records for 10 employees after excluding the records of the first five employees.

ANSWER: Select Employee ID, Login ID,Title
                   From HumanResources.Employee
                   Order by Emp Id
                   OFFSET 5 Rows
                   Fetch next 10 Rows only 

6.Display the different types of the credit cards used for purchasing products.

ANSWER: Select distinct Cardtype
                   From Sales.CreditCard

7.Each time the Salary slip for an employee is generated, the referral bonus(if present) has to be calculated and printed in the salary slip.

ANSWER: 




8.New Heights is a training institute that provides courses on various nontechnical subjects, such as personality improvement and foreign languages. Xuan, the Database Designer, has made the following relations to represent the data about students, and modules covered in the batches:


  • STUD-ID: Student's id (unique)
  • NAME:Name of students
  • BATCH-NO: Batch number(one student can belong to only one batch)
  • SLOT: Time and day when the batch of the students attends the class
  • MODULE: Module or subject(one batch will do several modules)
  • MARKS: Marks obtained in a module test

Xuan now needs to simplify the above relations by normalizing them.

ANSWER:



9.
         

ANSWER:





10. Consider the following Student Table.




 ANSWER: 








11.Consider the following Purchase Details table.




ANSWER: 





No comments:

Post a Comment