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

Mysql Lab Exam

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

-- Q1- Display details of the suppliers where commission percentage

-- is null and salary in the range 500000 to 650000 and gender is male.
where commission is null and
salary between (500000 and 650000) and
gender = 'male';

D/03 S/03 Michael David male 527000

-- Q2- Write a query to Display manager who born after 17th June 1992.
select * from manager where DOB>'1992-06-17';

M/03 Yassin Mpare male 1998-06-16 3300000


M/05 James Kanyala male 1993-01-11 4300000

-- Q3- Write a query to print customers full name (concating FNAME


and LNAME column) in lowercase format. (e.g jacob denis)

select lower(concat(fname, " ", lname )) as name from customer;

jacob denis
lameck goffrey
frank desdery
john justin
vicent victor

-- Q4- Write a query to Get the first 4 characters of “LNAME”


column from supplier table.

select left(lname,4) from supplier;

Jose
Will
Davi
Halt
Stev

-- Q5- Write a query to Display the FNAME for Manager where


FNAME contain character 'e' after 2nd position.
select fname from manager where fname like '__e%';

Steven

-- Q6- Write a query to Display suppliers where the first name or


last name contain 3rd letter 'v'.

select * from supplier


where fname like '__v%' or lname like '__v%';

D/01 S/01 David Joseph male 700000 23000


D/03 S/03 Michael David male 527000

-- Q7- Write a query to Find all customers which doesn't have any
product. (use sub-query)
select * from customer where customerid not in (select distinct customerid from
product);

5 Vicent Victor Bayport Financila

-- Q8- Write a query that gives manager firstname, customers firstname,


product name and supplier firstname for each product along with the
product code.(use join)

select c.fname, m.fname,p.product_name,s.fname,p.pcode from product p


left join department d using (deptno)
left join manager m using (manid)
left join supplier s using (supid)
left join customer c using (customerid);

c.fname m.fname p.product_name s.fname p.pcode


Jacob Steven Computer David 101
Jacob Steven Laptop David 102
Lameck Cecilia Toilet Paper Bruce 103
Frank Yassin Stake Meat Michael 104
John Glady Poutly Meat Michael 105
Lameck Glady Computer David 106

-- Q9- Write an SQL query to determine the 3rd highest salary of


manager without using TOP or limit method.

select max(salary) from manager where salary < (select max(salary) from manager
where salary not in (select max(salary) from manager));

4100000

-- Q10- Display all the PCODE(Product Code) which have more Price than
all the Computer Product_Name.(use Joins)

You might also like