0% found this document useful (0 votes)
24 views6 pages

Baitaptrenlop

Uploaded by

huyenthoaigoku3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views6 pages

Baitaptrenlop

Uploaded by

huyenthoaigoku3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

1

select o.*
from orders o
where o.salesman_id in (
select salesman_id
from salesman
where name like 'Paul Adam');

2
select *
from orders
where salesman_id in (
select salesman_id
from salesman
where city like 'London');

3
select o2.*
from orders o2
where o2.salesman_id = (
select o1.salesman_id
from orders o1
where o1.customer_id = 3007
);

4
select o2.*
from orders o2
where o2.purch_amt > (
select avg(o1.purch_amt)
from orders o1
where o1.ord_date = '10/10/2012'
)

5
select *
from orders
where salesman_id in (
select salesman_id
from salesman
where city like 'New York'
);

6
select commission
from salesman
where salesman_id in (
select salesman_id
from customer
where city like 'Paris');

7
select c2.*
from Customer c2
where c2.customer_id in (
select c1.customer_id
from Customer c1
where c1.customer_id + 2001 = (
select salesman_id
from salesman
where name like 'Mc Lyon'
)
);

8
select c2.grade, count(c2.customer_id)
from Customer c2
where c2.grade > (
select avg(c1.grade)
from customer c1
where c1.city like 'New York'
)
group by c2.grade

9
select *
from orders
where salesman_id in (
select s2.salesman_id
from salesman s2
where s2.commission = (
select max(s1.commission)
from salesman s1
)
)
;
10
select o1.ord_no, o1.purch_amt, o1.ord_date, o1.customer_id, c1.cust_name
from Orders o1
join Customer c1
on o1.salesman_id = c1.salesman_id
where o1.customer_id in (
select o2.customer_id
from Orders o2
where o2.ord_date = '2012-08-17');

11
select name, salesman_id
from Salesman
where salesman_id in (
select c2.salesman_id
from Customer c2
group by c2.salesman_id
having count(c2.customer_id) > 1
);

12
select *
from orders o1
where purch_amt > (
select avg(purch_amt)
from orders o2
where o2.customer_id = o1.customer_id
);

13
select *
from orders o1
where purch_amt >= (
select avg(purch_amt)
from orders o2
where o2.customer_id = o1.customer_id
);

14
select o2.ord_date, sum(o2.purch_amt)
from orders o2
group by ord_date
having sum(o2.purch_amt) > (
select max(o1.purch_amt) + 1000.00
from orders o1
where o1.ord_date = o2.ord_date
);

15
select customer_id, cust_name, city
from customer
where exists (
select *
from customer
where city = 'London');

16
select *
from salesman
where salesman_id in (
select c1.salesman_id
from customer c1
group by (c1.salesman_id)
having count(c1.customer_id) >= 2
);

17
select *
from salesman
where salesman_id in (
select c1.salesman_id
from customer c1
group by (c1.salesman_id)
having count(c1.customer_id) = 1
);

18
select *
from salesman
where salesman_id in (
select distinct salesman_id
from orders
where customer_id in (
select customer_id
from orders
group by customer_id
having count(ord_no) >= 2
)
);

19
select *
from salesman
where salesman_id in (
select distinct s1.salesman_id
from salesman s1
join customer c1
on s1.salesman_id = c1.salesman_id
where s1.city = c1.city);

20
select *
from salesman
where city in
(select city
from customer);

21
select *
from salesman a
where exists
(select *
from customer b
where a.name < b.cust_name)

22
select *
from customer
where grade > any (
select grade
from customer
where city < 'New York');

23
select *
from orders
where purch_amt > any (
select purch_amt
from orders
where ord_date = '2012-09-10');

24
select *
from orders
where purch_amt < any (
select purch_amt
from orders o1
join customer c1
on o1.customer_id = c1.customer_id
where c1.city = 'London'
)

25
select *
from orders
where purch_amt < (
select max(purch_amt)
from orders o1, customer c1
where o1.customer_id = c1.customer_id and c1.city = 'London')

26
select *
from customer
where grade > all (
select grade
from customer
where city = 'New York');

27
select s1.name, s1.city, sum(o1.purch_amt) as total
from salesman s1
join orders o1
on s1.salesman_id = o1.salesman_id
where s1.city in (
select distinct city
from customer)
group by s1.salesman_id, s1.name, s1.city

28
select *
from customer
where grade <> all (
select grade
from customer
where city = 'London' and not grade is null)

29
select *
from customer
where grade <> all (
select grade
from customer
where city = 'Paris')

30
select *
from customer
where not grade = any (
select grade
from customer
where city = 'Dallas');

33
select i.pro_name, i.pro_price
from company_mast c, item_mast i
where c.com_id = i.pro_com and
i.pro_price = (
select max(i.pro_price)
from item_mast i
where i.pro_com = c.com_id)

34
select *
from emp_details
where emp_lname = 'Gabriel' or emp_lname = 'Dosio'

35
select *
from emp_details
where emp_dept = 89 or emp_dept = 63

36
select t.emp_lname, t.emp_fname
from emp_department m, emp_details t
where m.dpt_code = t.emp_dept and m.dpt_allotment > 50000

37
select *
from emp_department
where dpt_code in (
select dpt_code
from emp_department
where dpt_allotment >= all (
select dpt_allotment
from emp_department))

38
select dpt_name
from emp_department
where dpt_code in (
select emp_dept
from emp_details
group by emp_dept
having count(*) > 2);

39
select emp_fname, emp_lname
from emp_details
where emp_dept in (
select dpt_code
from emp_department
where DPT_ALLOTMENT = (
select min(DPT_ALLOTMENT)
from emp_department
where DPT_ALLOTMENT > (
select min(DPT_ALLOTMENT)
from emp_department
)
)
);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy