SQL Test 1

    Question 1SQL Definition and Purpose

    What is SQL, and why is it used?

    Question 2VARCHAR vs CHAR Data Types

    What is the difference between VARCHAR and CHAR data types?

    Question 3CREATE TABLE vs CREATE DATABASE

    What is the difference between CREATE TABLE and CREATE DATABASE commands?

    Question 4GROUP BY Purpose and Function

    What is the purpose of GROUP BY clause in SQL?

    Question 5SELECT * vs SELECT Column Names

    What is the difference between SELECT * and SELECT column_name?

    Question 6Creating a Basic Index

    You want to improve the performance of queries that search for customers by their last name in a customers table. Which SQL statement correctly creates an index on the last_name column?

    Question 7NOT Operator Usage

    How does the NOT operator work in SQL?

    Question 8INNER JOIN Basic Concept

    What does INNER JOIN do in SQL?

    Question 9OUTER JOIN Types Overview

    What are the types of OUTER JOINs in SQL?

    Question 10Purpose of Aggregate Functions

    What is the main purpose of aggregate functions in SQL?

    Question 11Database vs Table Distinction

    What is the difference between a database and a table?

    Question 12INT vs BIGINT Comparison

    What is the difference between INT and BIGINT data types?

    Question 13ALTER TABLE Capabilities

    What can the ALTER TABLE command do?

    Question 14HAVING vs WHERE Clause Usage

    What is the difference between HAVING and WHERE clauses?

    Question 15WHERE Clause Operators

    Which operators can be used in WHERE clause?

    Question 16Index Purpose and Benefits

    What is the primary purpose of an index in SQL?

    Question 17IN and BETWEEN Operators

    From a products table (product_id, product_name, category, price, supplier_id), select products in categories 'Electronics', 'Appliances', or 'Gadgets' with prices between $100 and $500, supplied by suppliers 101, 102, or 103.

    Question 18Basic INNER JOIN Syntax

    You have two tables: customers (customer_id, name) and orders (order_id, customer_id, order_date). You want to list all orders along with the name of the customer who placed each order.

    Question 19Basic LEFT OUTER JOIN

    You have two tables: customers (customer_id, name) and orders (order_id, customer_id, amount). You want to list all customers, including those who have not placed any orders, along with their order amounts (which will be NULL for customers with no orders).

    Question 20COUNT Function Variations

    From an employees table (emp_id, name, department, salary, phone), write a query to show total number of employees, number of employees with phone numbers, and number of unique departments.