Pertanyaan dan Jawaban Wawancara Paling Populer & Tes Online
Platform edukasi untuk persiapan wawancara, tes online, tutorial, dan latihan langsung

Bangun keterampilan dengan jalur belajar terfokus, tes simulasi, dan konten siap wawancara.

WithoutBook menghadirkan pertanyaan wawancara per subjek, tes latihan online, tutorial, dan panduan perbandingan dalam satu ruang belajar yang responsif.

Prepare Interview

Ujian Simulasi

Jadikan Beranda

Bookmark halaman ini

Langganan Alamat Email
Beranda / Subjek Wawancara / SQL Query
WithoutBook LIVE Mock Interviews SQL Query Related interview subjects: 24

Interview Questions and Answers

Know the top SQL Query interview questions and answers for freshers and experienced candidates to prepare for job interviews.

Total 70 questions Interview Questions and Answers

The Best LIVE Mock Interview - You should go through before interview

Know the top SQL Query interview questions and answers for freshers and experienced candidates to prepare for job interviews.

Interview Questions and Answers

Search a question to view the answer.

Experienced / Expert level questions & answers

Ques 2

Write a SQL query to find the third highest salary from an Employee table.

SELECT MAX(salary) FROM Employee WHERE salary < (SELECT MAX(salary) FROM Employee WHERE salary < (SELECT MAX(salary) FROM Employee));
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 4

Write a SQL query to find the average salary of employees in each department, excluding departments with fewer than five employees.

SELECT department, AVG(salary) FROM Employee GROUP BY department HAVING COUNT(*) >= 5;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 6

What is the purpose of the SQL TRIGGER?

A TRIGGER is a set of instructions that are automatically executed (or 'triggered') in response to specific events, such as INSERTs, UPDATEs, or DELETEs, on a particular table.

Example:

CREATE TRIGGER trigger_name BEFORE INSERT ON table FOR EACH ROW BEGIN -- trigger logic END;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 7

Explain the purpose of the SQL ROLLUP operator.

The ROLLUP operator is used in conjunction with the GROUP BY clause to generate subtotals and grand totals for a set of columns in the result set.

Example:

SELECT department, city, SUM(salary) FROM Employee GROUP BY ROLLUP (department, city);
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 9

Explain the purpose of the SQL LEAD() and LAG() functions.

The LEAD() function is used to access the next row's data in the result set, while the LAG() function is used to access the previous row's data.

Example:

SELECT employee_name, salary, LEAD(salary) OVER (ORDER BY salary) AS NextSalary FROM Employee;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 10

What is the purpose of the SQL CROSS APPLY operator?

The CROSS APPLY operator is used to invoke a table-valued function for each row returned by the outer query. It is similar to the INNER JOIN clause.

Example:

SELECT * FROM table1 CROSS APPLY function(table1.column) AS alias;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 11

Write a SQL query to find the employees who have the highest salary in each department.

SELECT department, employee_name, salary FROM (SELECT department, employee_name, salary, ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS rnk FROM Employee) AS ranked WHERE rnk = 1;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 12

Explain the purpose of the SQL MERGE statement.

The MERGE statement is used to perform insert, update, or delete operations on a target table based on the results of a join with a source table. It is also known as an 'upsert' operation.

Example:

MERGE INTO target_table USING source_table ON condition WHEN MATCHED THEN UPDATE SET column1 = value1 WHEN NOT MATCHED THEN INSERT (column1, column2) VALUES (value1, value2);
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 13

What is the purpose of the SQL WINDOW functions?

WINDOW functions perform a calculation across a set of table rows related to the current row. They are used with the OVER() clause to define a window or a subset of rows for the calculation.

Example:

SELECT employee_name, salary, AVG(salary) OVER (PARTITION BY department) AS AvgSalary FROM Employee;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 14

Write a SQL query to find the employees with the second-highest salary in each department.

SELECT department, employee_name, salary FROM (SELECT department, employee_name, salary, ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS rnk FROM Employee) AS ranked WHERE rnk = 2;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 15

Explain the purpose of the SQL XML functions (XMLAGG, XMLPARSE, XMLQUERY, etc.).

XML functions in SQL are used to process XML data. XMLAGG is used to concatenate XML values, XMLPARSE is used to convert a string to XML, and XMLQUERY is used to extract data from XML.
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 16

What is the purpose of the SQL PIVOT and UNPIVOT operators?

The PIVOT operator is used to rotate rows into columns, while the UNPIVOT operator is used to rotate columns into rows.

Example:

SELECT * FROM (SELECT department, salary FROM Employee) AS SourceTable PIVOT (SUM(salary) FOR department IN ([Dept1], [Dept2], [Dept3])) AS PivotTable;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 18

Explain the purpose of the SQL ROW and RANGE clauses in window functions.

ROW and RANGE are used in the OVER() clause of window functions to define the window or subset of rows for the calculation. ROW refers to a physical count, while RANGE considers values within a specified range.
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 19

Write a SQL query to find the employees with the highest salary in each department using the DENSE_RANK() function.

SELECT department, employee_name, salary FROM (SELECT department, employee_name, salary, DENSE_RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS rnk FROM Employee) AS ranked WHERE rnk = 1;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments
Ques 20

What is the purpose of the SQL TRY...CATCH statement?

The TRY...CATCH statement is used to handle errors in a SQL Server stored procedure. It allows for structured error handling and graceful error recovery.

Example:

BEGIN TRY -- SQL statements END TRY BEGIN CATCH -- Handling of errors END CATCH;
Simpan untuk Revisi

Simpan untuk Revisi

Bookmark item ini, tandai sebagai sulit, atau masukkan ke dalam set revisi.

Buka Perpustakaan Belajar Saya
Apakah ini membantu?
Add Comment View Comments

Most helpful rated by users:

Hak Cipta © 2026, WithoutBook.