SQL Test 3

    Question 1Primary Key vs Unique Key

    What is the difference between primary key and unique key?

    Question 2NULL Data Type Handling

    How do different data types handle NULL values?

    Question 3UPDATE with vs without WHERE

    What happens when you use UPDATE command without WHERE clause?

    Question 4GROUP BY with Multiple Columns

    How does GROUP BY work with multiple columns?

    Question 5SELECT with Pattern Matching and NULL Handling

    From a customers table (customer_id, first_name, last_name, email, phone), find all customers whose email ends with '@gmail.com' and phone number is not NULL, showing only first_name and email.

    Question 6Composite Index Usage

    What is a composite index and when should it be used?

    Question 7LIKE Wildcard Characters

    What are the standard wildcard characters used with LIKE operator?

    Question 8INNER JOIN Syntax Requirements

    What is required in INNER JOIN syntax?

    Question 9RIGHT JOIN Functionality

    How does RIGHT JOIN work in SQL?

    Question 10MIN and MAX Functions with Date Operations

    From an orders table (order_id, customer_id, order_date, total_amount), find the earliest order date, latest order date, lowest order amount, and highest order amount for each customer.

    Question 11Sorting Results

    Which query returns student names in ascending order?

    Question 12ENUM Data Type Usage

    What is ENUM data type and when should it be used?

    Question 13Data Insertion and Updates

    Insert a new employee (id=101, name='John Doe', dept='IT', salary=75000) into employees table, then update all IT employees' salaries by 10% increase.

    Question 14HAVING without GROUP BY

    Can HAVING clause be used without GROUP BY?

    Question 15SELECT DISTINCT Usage

    What does SELECT DISTINCT do?

    Question 16Index Maintenance and Updates

    How are indexes maintained when table data changes?

    Question 17LIKE Operator with Wildcards

    From a customers table (customer_id, first_name, last_name, email, phone), find customers whose first name starts with 'J', email contains 'gmail', and phone number ends with '123'.

    Question 18INNER JOIN on Multiple Tables

    You have three tables: orders (order_id, customer_id, product_id), customers (customer_id, name), and products (product_id, product_name). You want to list all orders with the customer name and product name for each order.

    Question 19FULL OUTER JOIN Use Case

    You have two tables listing projects: assigned_projects (project_id, project_name, owner) and completed_projects (project_id, completion_date). You need a complete list of all projects, showing their completion date if they are finished, and their owner if they are assigned. Some projects might be assigned but not finished, and others might be finished but not in the assigned list (e.g., historical projects).

    Question 20Calculating Average

    Which aggregate function calculates the average salary of employees?