National University: Name: Roll No: Section: Quiz No. 2 Database System Date: Duration: 45 Minute(s)
National University: Name: Roll No: Section: Quiz No. 2 Database System Date: Duration: 45 Minute(s)
Question#1:
Retrieve Employee City, Employee ID, First Name, Last Name from Table sorted by city name
(Descending)?
Select city,EmployeeId,FirstName,LastName from employee order by city DESC;
Question#2:
Retrieve number of Employee group by their cities?
Select count(*),city from employee group by City;
Question#3:
Show First name, Last name and City of Employees who are hired after ‘1/1/1993’ or live in
Kikland?
Select FirstName,LastName,City from employee where HireDate>'1/1/1993' or
city='Kirkland';
Question#4:
Find all of the employees whose first name does not start with 'M' or 'A'
Select * from employee where FirstName not like 'M%' and FirstName not like 'A%';
SALESMAN
1
National University
Of Computer & Emerging Sciences Faisalabad -Chiniot Campus
Question#5
Write a SQL statement to display list of names of all salesman in sorted form w.r.t their
commission?
Select name from SALESMAN order by commission;
Question#6
Write a SQL statement to salesman id and name of all salesmen whose Commission is between
0.12 to 0.14
select salesman_id,name from SALESMAN where commission between 0.12 and 0.14;
Question#7
Write a SQL statement to display name and City of all salesmen whose Commission is greater
than 0.13 or their names end with ‘e’ or ‘x’
select name,city from SALESMAN where commission>0.13 or name Like '%e' or name like '%x';
Question#8
Write SQL statement to List the number of salesman in each city. Only include salesman with commission
more than 0.12.
select count(*),city from SALESMAN where commission>0.12 group by city ;
Orders
Question#9
Write a SQL statement to display List the amount of orders in ascending order.
2
National University
Of Computer & Emerging Sciences Faisalabad -Chiniot Campus
Question#10
Write a SQL statement to display order number, amount and date of all orders that are placed
before 1-sept-2012.
Select ord_no,purch_amt,ord_date from Orders where ord_date<'2012-09-01';
CUSTOMER
Question#11
Write a SQL statement to display all the information for those customers sorted by their city.
select count(*),city from CUSTOMER where grade between 100 and 200 and city!='Paris'
group by city;