1.
Write a query to display the customer_name and amount for transactions where the
amount is between 5000 and 10000.
select customer_name, amount from bank_transactions where amount between 5000 and
10000;
2. Write a query to delete all records from bank_transactions where the amount is less than
or equal to 2000.
delete from bank_transactions where amount<=2000;
[Link] a query to count the total number of records in bank_transactions.
select count(*) from bank_transactions;
4. Write a query to calculate the average transaction amount and display it as avg_salary
select AVG(amount) AS avg_salary from bank_transactions;
5. Write a query to find the minimum and maximum transaction amounts
select min(amount), MAX(amount) from bank_transactions;
6. Write a query to display each department and the count of transactions, but only for
departments with more than 2 transactions.
select department,count(department) from bank_transactions group by department having
count(department)>2;
7. Write a query to display all customer names in uppercase.
select UPPER(customer_name) from bank_transactions;
8. Write a query to display all transactions where the amount is greater than the average
transaction amount.
select * from bank_transactions where amount>(select avg(amount) from bank_transactions);
9. Write a query to display the customer_name and amount for transactions where the
amount is between 5000 and 10000.
select customer_name, amount from bank_transactions where amount between 5000 and
10000;
10. Write a query to increase every transaction amount by 10%.
update bank_transactions set amount=(amount+(amount*0.10));
11. Write a query to display each department and the total transaction amount for that
department.
select department, sum(amount) from bank_transactions group by department;
12. Write a query to display each department and the number of transactions in that
department
select department, count(*) from bank_transactions group by department;
13. Write a query to display each department and the average transaction amount.
select department, avg(amount) from bank_transactions group by department;
14. Write a query to display each department and the minimum transaction amount.
select department, min(amount) from bank_transactions group by department;
15. Write a query to display each department and the maximum transaction amount.
select department, max(amount) from bank_transactions group by department;
16. Write a query to display each department and the total transaction amount, but only for
departments where the total exceeds 50,000
select department, sum(amount) from bank_transactions group by department having
sum(amount)>50000;
[Link] a query to display each department and the number of transactions, but only for
departments with more than 5 transactions.
select department, count(*) from bank_transactions group by department having count(*)>5;
18. Write a query to display each department and the average transaction amount, but only
for departments where the average exceeds 3000.
select department, avg(amount) from bank_transactions group by department having
avg(amount)>3000;
19. Write a query to display each department and the maximum transaction amount, but only
for departments where the maximum exceeds 9500
select department, max(amount) from bank_transactions group by department having
max(amount)>9500;
20. Write a query to display each department and the minimum transaction amount, but only
for departments where the minimum is less than 2000.
select department, min(amount) from bank_transactions group by department having
min(amount)<2000;
21. Write a query to display each department and the average transaction amount, but only
for departments where the average is between 4000 and 5000.
select department, avg(amount) from bank_transactions group by department having
avg(amount) between 4000 and 5000;
22. Write a query to display each department and the total transaction amount, ordering the
results by sum
select department, sum(amount) from bank_transactions group by department order by ;
23. Write a query to display the top 5 transactions with the highest amounts, showing
customer_name and amount.
select customer_name, amount from bank_transactions order by amount desc fetch first 5 rows
only;
24. Write a query to display each city and the total transaction amount for that city.
select city, sum(amount) FROM bank_transactions group by city;
25. Write a query to display the customer_name, amount, and transaction_id for transactions
where the amount is greater than all amounts of transaction ID 15.
select customer_name,amount, transaction_id from bank_transactions where amount > ALL
(select amount from bank_transactions where transaction_id = 15);
26. Write a query to update the transaction amount to 12,000 for the record where
transaction_id is 2.
update bank_transactions set amount=12000 where transaction_id=2;