POSTGRESQL DATABASE INTERVIEW QUESTIONS

Course:PostgreSQL
Chapter:Chapter 7 - DQL (Data Query Language)
Topic:SELECT *
Questions Count:57
1

What does the SELECT * statement do in PostgreSQL?

Explanation:
2

How would you use SELECT * to retrieve all data from a table named customers?

Explanation:
3

Can you explain the difference between SELECT * and specifying column names in the SELECT statement?

Explanation:
4

Why might using SELECT * in a production environment be discouraged?

Explanation:
5

How can using SELECT * affect query optimization in PostgreSQL?

Explanation:
6

Is there any way to limit the number of rows returned when using SELECT * in PostgreSQL?

Explanation:
7

How does PostgreSQL handle SELECT * in terms of internal query processing and execution plans?

Explanation:
8

How can the use of SELECT * impact data transfer and network performance in a distributed database setup?

Explanation:
9

What are some best practices for using SELECT * in complex queries involving multiple joins and subqueries?

Explanation:
10

In both PostgreSQL and Oracle, what are the implications of using SELECT * in a view definition, and how might this affect future schema changes?

Explanation:
11

How do you query a hierarchy of employees in PostgreSQL when the employee table has a manager ID that points to their supervisor?

Explanation:
12

How can you represent a hierarchy of employees in PostgreSQL?

Explanation:
13

How would you query all employees reporting directly to a specific manager in PostgreSQL?

Explanation:
14

How can you retrieve all employees under a specific manager, including indirect reports (multi-level hierarchy)?

Explanation:
15

How do you determine the hierarchy level (depth) of an employee in the organization?

Explanation:
16

To fetch ALTERNATE records from a table. (EVEN NUMBERED)

Explanation:
17

To select ALTERNATE records from a table. (ODD NUMBERED)

Explanation:
18

Find the 3rd MAX salary in the emp table.

Explanation:
19

Find the 3rd MIN salary in the emp table.

Explanation:
20

Select FIRST n records from a table.

Explanation:
21

Select LAST n records from a table

Explanation:
22

List dept no., Dept name for all the departments in which there are no employees in the department.

Explanation:
23

How to get 3 Max salaries ?

Explanation:
24

How to get 3 Min salaries ?

Explanation:
25

How to get nth max salaries ?

Explanation:
26

Select DISTINCT RECORDS from emp table.

Explanation:
27

How to delete duplicate rows in a table?

Explanation:
28

Count of number of employees in department wise.

Explanation:
29

Suppose there is annual salary information provided by emp table. How to fetch monthly salary of each and every employee?

Explanation:
30

Select all record from emp table where deptno =10 or 40.

Explanation:
31

Select all record from emp table where deptno=30 and sal>1500.

Explanation:
32

Select all record from emp where job not in SALESMAN or CLERK.

Explanation:
33

Select all record from emp where ename in 'BLAKE','SCOTT','KING'and'FORD'.

Explanation:
34

Select all records where ename starts with ‘S’ and its lenth is 6 char.

Explanation:
35

Select all records where ename may be any no of character but it should end with ‘R’.

Explanation:
36

Count MGR and their salary in emp table.

Explanation:
37

In emp table add comm+sal as total sal .

Explanation:
38

Select any salary <3000 from emp table.

Explanation:
39

Select all salary <3000 from emp table.

Explanation:
40

Select all the employee group by deptno and sal in descending order.

Explanation:
41

How can I create an empty table emp1 with same structure as emp?

Explanation:
42

How to retrive record where sal between 1000 to 2000?

Explanation:
43

Select all records where dept no of both emp and dept table matches.

Explanation:
44

If there are two tables emp1 and emp2, and both have common record. How can I fetch all the recods but common records only once?

Explanation:
45

How to fetch only common records from two tables emp and emp1?

Explanation:
46

How can I retrive all records of emp1 those should not present in emp2?

Explanation:
47

Count the totalsa deptno wise where more than 2 employees exist.

Explanation:
48

Query to find second highest salary of Employee

Explanation:
49

Find nth maximum salaries

Explanation:
50

Fetch ALTERNATE records from a table. (EVEN Numbered)

Explanation:
51

Select First n records from a table

Explanation:
52

Select Last n records from a table

Explanation:
53

Delete Duplicate Rows in a table

Explanation:
54

Count MGR and their salary in employee table

Explanation:
55

Add comm+salary as total salary

Explanation:
56

Retrieve record from salary between 1000 to 2000

Explanation:
57

Retrieve department-wise totalsalary for departments with more than 2 employees

Explanation: