Database | SQL | PL- SQL Interview Questions

Write the complete query for Fetching the data from tables.
select         column1, column2 .
from          table_name
where       <condition>
group by  <columns> having <conditions>
order by   <columns>

Write the SQL for finding the second highest value.
mysql> select * from employee;
+---------+--------+
| name    |  salary |
+---------+--------+
| Dhiraj   |   1000 |
| Dhiraj   |   1000 |
| Kunal    |   2000 |
| Aryan    |   3000 |
+---------+--------+

mysql> select * from employee emp where 2=(select count(distinct salary) from employee where emp.salary>=salary);

+-------+--------+
| name  | salary |
+-------+--------+
| Kunal |   2000 |
+-------+--------+


Write the code to find the duplicate records in a table.
mysql> select * from employee;
+---------+--------+
| name    |  salary |
+---------+--------+
| Dhiraj   |   1000 |
| Dhiraj   |   1000 |
| Kunal    |   2000 |
| Aryan    |   3000 |
+---------+--------+

mysql> select name,salary from employee group by name, salary having count(*)>1;

+--------+--------+
| name   | salary |
+--------+--------+
| Dhiraj |   1000 |
+--------+--------+

What are DDL and DML?

What is Join? Write the query for inner join.

What is natural join?

What are the usage of Self  Join?

What is outer join and what are the types of outer joins, explain briefly?

What are the differences between SQL, PL-SQL, Procedures & Triggers?

What are views and what are it's advantages?

What are the differences between Truncate and Delete command?






Comments

Popular posts from this blog

Core Java Interview Question's Answers - 1

Mobileum Bangalore Core Java Developer Interview

Learning Java For Interview Purpose. Day - 1