Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY

Write the SELECT queries to do the following:-

Note : To solve below queries use “hr” database

1. Write a query to display the first_name, last_name using


alias name “First Name", "Last Name".

2. Write a query to get unique department ID from employee


table.

3. Write a query to get all employee details from the employee


table order by first name, descending.

4. Write a query to get the names (first_name, last_name),


salary, PF of all the employees (PF is calculated as 15% of
salary).

5. Write a query to get the employee ID, names (first_name,


last_name), salary in ascending order of salary.

6. Write a query to get the total salaries payable to employees.

7. Write a query to get the maximum and minimum salary


from employees table.

8. Write a query to calculate 171*214+625.

9. Write a query to get the names (for example Ellen Abel,


Sundar Ande etc.) of all the employees from employees table.
10. Write a query to select first 10 records from a employees
table.
Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY

11. Display first name and join date of the employees who is
either IT Programmer or Sales Man.

12. Display details of employee with ID 150 or 160.

13. Display first name, salary, commission pct, and hire date for
employees with salary less than 10000.

14. Display employees where the first name or last name starts
with S.

15. Display details of jobs in the descending order of the title.

16. Display details of the employees where commission


percentage is null and salary in the range 5000 to 10000 and
department is 30.

17. Display employees first_name,email who are working in


“Executive” department.

18. Display unique contry_id from locations table.

19. Display all employees whoe have job_id IT_PROG and


FI_ACCOUNT.

20. Display all countries in ascending order.

Note : To solve below queries use “spj” database


Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY
1. Display all the data from the S table.

2. Display only the S# and SNAME fields from the S table.

3. Display the PNAME and COLOR from the P table for the
CITY=”London”.

4. Display all the Suppliers from London.

5. Display all the Suppliers from Paris or Athens.

6. Display all the Projects in Athens.

7. Display all the Partnames with the weight between 12 and


14 (inclusive of both).

8. Display all the Suppliers with a Status greater than or equal


to 20.

9. Display all the Suppliers except the Suppliers from London.

10. Display only the Cities from where the Suppliers come
from.

11. Assuming that the Part Weight is in GRAMS, display the


same in
MILLIGRAMS and KILOGRAMS.

12. Display the Supplier table in the descending order of CITY.


13. Display the Part Table in the ascending order of CITY and
within the city in the ascending order of Part names.
Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY
14. Display all the Suppliers with a status between 10 and 20.

15. Display all the Parts and their Weight, which are not in the
range of 10 and

Note : To solve below queries use “northwind” database

1. Write a query to get Product name and quantity/unit

2. Write a query to get current Product list (Product ID and


name)

3. Write a query to get Product list (id, name, unit price)


where current products cost less than $20.

4. Write a query to get Product list (id, name, unit price)


where products cost between $15 and $25.

5. Write a query to get Product list (name, unit price) of above


average price.

6. Write a query to get CategoryName and Description from


the Categories table.

7. Write a query to get ContactName, CompanyName,


ContactTitle and Phone from the Customers table.

8. Write a query to get EmployeeID, Title, FirstName, LastName,


and Region from the Employees table.
9. Write a query to get RegionID and RegionDescription from
the Region table.
Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY
10. Write a query to get CompanyName, Fax, Phone and
HomePage from the Suppliers table.

11. Write a query to get CategoryName and Description from


the Categories table sorted by CategoryName.

12. Write a query to get ContactName, CompanyName,


ContactTitle, and Phone from the Customers table sorted by
Phone.

13. Create a report showing employees' first and last names


and hire dates sorted from newest to oldest employee.

14. Create a report showing Northwind's orders sorted by


Freight from most expensive to cheapest. Show OrderID,
OrderDate, ShippedDate, CustomerID, and Freight.

15. Write a query to get CompanyName, Fax, Phone,


HomePage and Country from the Suppliers table sorted by
Country in descending order and then by CompanyName in
ascending order.

16. Create a list of employees showing title, first name, and


last name. Sort by Title in ascending order and then by
LastName in descending order.

17. Create a report showing all the company names and


contact names of Northwind's customers in Buenos Aires.

18. Create a report showing the product name, unit price and
quantity per unit of all products that are out of stock.
Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY
19. Create a report showing the order date, shipped date,
customer id, and freight of all orders placed on May 19, 1997.

20. Create a report that shows the company name, contact


name and fax number of all customers that have a fax number.

21. Create a report that shows the first and last name of all
employees who do not report to anybody.

Note : To solve below queries use “sales” database

1. Which field of the Customers table is the primary key?

2. What is the 4 th column of the Customers table?

3. What is another word for row? For column?

4. Why isn’t it possible to see the first five rows of a table?

5. Write a select command that produces the order number,


amount, and date forall rows in the Orders table.

6. Write a query that produces all rows from the Customers


table for which the salesperson’s number is 1001.

7. Write a query that displays the Salespeople table with the


columns in the following order: city, sname, snum, comm.
8. Write a select command that produces the rating followed
by the name of each customer in San Jose.
Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY
9. Write a query that will produce the snum values of all
salespeople from the Orders table (with the duplicate values
suppressed).

10. Write a query that will give you all orders for more than
Rs. 1,000.

11. Write a query that will give you the names and cities of all
salespeople in London with a commission above 0.10.

12. Write a query on the Customers table whose output will


exclude all customers with a rating <= 100, unless they are
located in Rome.

13. What will be the output from the following query?


Select * from Orders
where (amt < 1000 OR
NOT (odate = ‘1990-10-03’
AND cnum > 2003));

14. What will be the output of the following query?


Select * from Orders
where NOT ((odate = ‘1990-10-03’ OR snum >1006) AND amt
>= 1500);

15. What is a simpler way to write this query?


Select snum, sname, city, comm from Salespeople
Where (comm > .12 or comm < .14);

16. Write a query that selects all of the customers serviced by


Peel or Motika.
(Hint:the snum field relates the two tables to one another).
Sunbeam Institute Of Technology,Pune & Karad

DATABASE TECHNOLOGY

17. Write a query that selects all orders except those with
zeroes or NULLs in the amt field.

You might also like