Hirenexa Testing – Sql Interview questions
-- =====================================================
-- BASIC SQL QUERIES FOR AUTOMATION TESTING INTERVIEWS
-- =====================================================
-- 1. Select all records from a table
SELECT * FROM employees;
-- 2. Select specific columns
SELECT employee_id, employee_name
FROM employees;
-- 3. Filter records using WHERE
SELECT *
FROM employees
WHERE department = 'QA';
-- 4. Use AND / OR conditions
SELECT *
FROM employees
WHERE department = 'QA'
AND salary > 50000;
-- 5. Sort records using ORDER BY
SELECT *
FROM employees
ORDER BY salary DESC;
Hirenexa Testing – Sql Interview questions
-- 6. Count records
SELECT COUNT(*) AS total_employees
FROM employees;
-- 7. Group data using GROUP BY
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department;
-- 8. Find duplicate records
SELECT email, COUNT(*)
FROM employees
GROUP BY email
HAVING COUNT(*) > 1;
-- 9. Join two tables
SELECT e.employee_name, d.department_name
FROM employees e
INNER JOIN departments d
ON e.department_id = d.department_id;
-- 10. Update a record
UPDATE employees
SET salary = 60000
WHERE employee_id = 101;
Hirenexa Testing – Sql Interview questions
-- =====================================================
-- BONUS: Frequently Asked Interview Query
-- Find the second highest salary
-- =====================================================
SELECT MAX(salary)
FROM employees
WHERE salary < (
SELECT MAX(salary)
FROM employees
);
-- =====================================================
-- COMMON INTERVIEW TOPICS
-- =====================================================
-- 1. Difference between WHERE and HAVING
-- 2. Types of JOINs
-- 3. DELETE vs TRUNCATE vs DROP
-- 4. Primary Key vs Foreign Key
-- 5. SQL usage in Selenium/Test Automation
-- =====================================================