0% found this document useful (0 votes)
17 views

SQL Code 1

Uploaded by

Sriraman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

SQL Code 1

Uploaded by

Sriraman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

SELECT Customer_Id, name, sum(amount) As total_amount


from Table
group by Customer_Id
having year = '2023';

2. SELECT Department_name, avg(salary) as average_salary


from table
group by Departmemnt_name
order by avg(salary) desc;

3. SELECT d.department_name, max(select count(employee_id) group by department_name)


as highest_number
from employees e join departments d on e.department_id = d.department_id;

4. SELECT customer_id, count(order_id as No_of_orders


from order
group by customer_id;

6. SELECT product_id, sum(quantity)


from transactions
where transcation_date between '1-5-2024' and '30-5-2024'
group by product_id
limit 3;

7. SELECT employee_id, employee_name, salary


from emploees e join managers m on e.manager_id = m.manager_id
where m.salary<e.salary;

1. SELECT Customer_Id, name, sum(amount) As total_amount


from Table
group by Customer_Id
having year = '2023';

2. SELECT Department_name, avg(salary) as average_salary


from table
group by Departmemnt_name
order by avg(salary) desc;

3. SELECT d.department_name, max(select count(employee_id) group by department_name)


as highest_number
from employees e join departments d on e.department_id = d.department_id;

4. SELECT customer_id, count(order_id as No_of_orders


from order
group by customer_id;

6. SELECT product_id, sum(quantity)


from transactions
where transcation_date between '1-5-2024' and '30-5-2024'
group by product_id
limit 3;

7. SELECT employee_id, employee_name, salary


from emploees e join managers m on e.manager_id = m.manager_id
where m.salary<e.salary;

1. SELECT Customer_Id, name, sum(amount) As total_amount


from Table
group by Customer_Id
having year = '2023';

2. SELECT Department_name, avg(salary) as average_salary


from table
group by Departmemnt_name
order by avg(salary) desc;

3. SELECT d.department_name, max(select count(employee_id) group by department_name)


as highest_number
from employees e join departments d on e.department_id = d.department_id;

4. SELECT customer_id, count(order_id as No_of_orders


from order
group by customer_id;

6. SELECT product_id, sum(quantity)


from transactions
where transcation_date between '1-5-2024' and '30-5-2024'
group by product_id
limit 3;

7. SELECT employee_id, employee_name, salary


from emploees e join managers m on e.manager_id = m.manager_id
where m.salary<e.salary;

You might also like