You are on page 1of 3

SALARY based Questions

Below is simple query to find the employee whose salary is highest.

SELECT name, MAX(salary) as salary FROM employee

We can nest the above query to find the second largest salary.

SELECT name, MAX(salary) AS salary


FROM employee
WHERE salary < (SELECT MAX(salary)
FROM employee);

Finding Nth highest salary in a table is the most common question asked in
interviews. Here is a way to do this task using dense_rank() function. 

select * from(
select ename, sal, dense_rank()
over(order by sal desc)r from Employee)
where r=&n;

 Explain what is tracing level and what are the types?

Tracing level is the amount of data stored in the log files. Tracing level can be
classified in two Normal and Verbose. Normal level explains the tracing level
in a detailed manner while verbose explains the tracing levels at each and
every row.

8) Explain what is Grain of Fact?


Grain fact can be defined as the level at which the fact information is stored. It
is also known as Fact Granularity

9) Explain what factless fact schema is and what is Measures?

A fact table without measures is known as Factless fact table. It can view the
number of occurring events. For example, it is used to record an event such
as employee count in a company.

The numeric data based on columns in a fact table is known as Measures

10) Explain what is transformation?

A transformation is a repository object which generates, modifies or passes


data. Transformation are of two types Active and Passive

What is the difference between DELETE and TRUNCATE?


Answer: The differences are:
 The basic difference in both is DELETE command is DML command and the
TRUNCATE command is DDL.
 DELETE command is used to delete a specific row from the table whereas the
TRUNCATE command is used to remove all rows from the table.
 We can use the DELETE command with WHERE clause but cannot use the
TRUNCATE command with it.

How to write a query to show the details of a student from Students table whose
name start with K?
Answer: Query:
SELECT * FROM Student WHERE Student_Name like ‘K%’;

Difference between TRUNCATE, DELETE and DROP commands?


Answer:
 DELETE removes some or all rows from a table based on the condition. It can be
rolled back.
 TRUNCATE removes ALL rows from a table by de-allocating the memory pages.
The operation cannot be rolled back
 DROP command removes a table from the database completely.

How can we avoid duplicating records in a query?


Answer: By using the DISTINCT keyword, duplication of records in a query can be avoided.

You might also like