Create Database SelfExercis
Create Database SelfExercis
use SelfExercis;
drop database SelfExercis;
('004','Fatuma','Semera','547'),
('005','Kumsa','Ambo','1678'),
('006','Dawit','Bahir
dar','598');
---3. Write a query to find all orders with order amounts which are above average
amounts for their customers
select *from OrderS where Purch_amt>(select avg(Purch_amt) from OrderS);
--or
select avg(Purch_amt) from OrderS;
select *from OrderS where Purch_amt> 65415;
--4. Find the name of the customer who has the smallest purch-amt?
select min(Purch_amt) from OrderS;
-- 5. Write a syntax that displays all salesman name containing a letter “D”.
select *from Salesman where Name like '%d%';
--6. Write a syntax that displays all Salesman ID, name and City having commision >1000
and came from addis Ababa in descending order by their name
select Salesmanid,Name,City from Salesman where Commission <1000 and City='AA';
-- 7. Find the names of all customers except their city in AA and Bahir Dar
select * from Customer where City not in ('Bahir Dar', 'AA');
delete from Customer where Cust_name='Umer' and Salesmanid in(select *from Salesman
where Salesmanid='006');
-- delete from Customer where Salesmanid= Salesmanid (select *from Salesman
Cust_name='Umer' AND Salesmanid='006');
--9. Write a syntax that displays Salesmanall customers whose Salesman city address
is AA.
select *from Customer where Salesmanid in(select *from Salesman where City='AA');
--or
select *from Customer, Salesman where Customer.Salesmanid= Salesman.Salesmanid
and Salesman.City='AA';
--10. Write a syntax that displays all customers whose Purch_amt is between 5000 and
9000).
select *from OrderS;
select *from Customer, OrderS where Customer.Cust_id= OrderS.Cust_id and
OrderS.Purch_amt between 50000 and 90000;
--11. Write a query to display all the orders which values are greater than the
average order value for 19th December 2012