Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

SQL INTERVIEW QUESTIONS

-----------------------
1.IDENTIFYING DUPLICATES AND DELETEING DUPLICATES

To delete the duplicate records we need to first find all the distinct
records. In duplicate records, every data is the same except row_id
because row_id is the physical address that the record occupies. So we find
the distinct row id where data are distinct in each column and then delete all the
rows with row_id that are not in the above query.

2.FIND 2 MAX SALARY


----------------------
select max(salary)from employees where salary<(select max(salary)from
employees);

3.ROWNUM AND ROWID DIFF


-----------------------

ROWID rowid is a permanent unique identifier for that row


rowid wont refer another row.

ROWNUM rownum is temporary identifier for row.


rownum will refer another row.

4. CASE AND DECODE DIFF


--------------------------
DECODE DECODE is a function.
DECODE is not used in the WHERE clause.
DECODE can be used only in SQL.
DECODE works with equality check(=)
DECODE works with different data types.
DECODE does not pass as a parameter, Because DECODE only works with SQL
Statements.

CASE CASE is a statement.


CASE is used in the WHERE clause.
CASE can be used both SQL and PL/SQL
CASE works with other relational operators like (>, <,>=, <=) as well
equality check (=).
CASE does not work with different data types
CASE does work as a parameter.

5.SQL & PLSQL CONCEPTS

SQL sql is a structured query language


The query executes a single operation at a time.
SQL is declarative
SQL is used in relational databases to execute various queries like create
table, delete table, insert into table, etc.
SQL does not support data variables.
SQL directly interacts with the database server.
SQL is easy to use and understand.
It is possible to embed SQL in PLSQL syntax as PLSQL is an extension of
SQL.
PLSQL plsql is a procedural language.
Group of operations is performed in a single block.
PL/SQL is procedural
PL/SQL is used to write program blocks, procedures, functions, cursors,
triggers, and packages.
PL/SQL provides support for variable constraints and data types.
PL/SQL does not directly interact with the database server.
Certain concepts of PL/SQL can be complex and prior knowledge might be
necessary.
Embedding PL/SQL in SQL syntax is not possible.

You might also like