You are on page 1of 2

select * from customers;

select * from orders;

select a.customer_id, a.name, a.credit_limit,


b.order_id, b.customer_id, b.status, b.salesman_id, b.order_date
from customers a, orders b
where a.customer_id = b.order_id;

select a.customer_id, a.name, a.credit_limit,


b.order_id, b.customer_id, b.status, b.salesman_id, b.order_date
from customers a inner join orders b on a.customer_id = b.order_id;

select a.customer_id, a.name, a.credit_limit,


b.order_id, b.status, b.order_date
from customers a left outer join orders b on a.customer_id = b.order_id
where status is not null;

select distinct * from agents;

select max(salary(max(salary)))from agents;

select max((select max(salary) from agents);

select * from agents;


select salary from agents
order by salary desc;

select max(salary) from agents


where salary not in (select max(salary) from agents);

select salary from agents


order by salary desc;

select max(salary) from agents


where salary not in (select max(salary) from agents);

select agent_name, salary, age from agents a1


where n - 1 = (select count(distinct salary)
from agents a2
where a2.salary > a1.salary);

with result as (
select distinct salary, row_number() over (order by salary desc ) as Rank from
agents)
select max(salary)
from result
where result.rank = 3

select max(salary)
from agents
where salary < (select max(salary) from agents
where salary < (select max(salary) from agents));

select max(salary) from agents


where salary < (select max(salary) from agents);

with result as (
select salary, dense_rank() over (order by salary desc ) as Rank from agents)
select max(salary)
from result
where result.rank = 8;

select salary from agents


order by salary desc;

with average_salary (avg_sal) as

select * from agents;

with avg_salary(s) as
(select cast(avg(salary) as int) from agents)
select * from agents v, avg_salary av
where v.salary > av.s;

select cast(avg(salary)as int) from agents A;

You might also like