SQL MCQs

Q.1 In “UPDATE Employees SET Age = Age + 1 WHERE Department IN (‘Sales’, ‘HR’) AND Age >= 30;”,
identify the error.

A. The IN operator
B. The AND operator
C. No error
D. The SET keyword

Shw me The Right Answer

Answer . C 

Q.2 Correct the syntax error in
“DELETE FROM Employees HAVING Age < 25;”

A. DELETE keyword
B. FROM keyword
C. HAVING keyword
D. No syntax error

Shw me The Right Answer

Answer . C 

Q.3 What is missing in the following statement?
“INSERT INTO Employees (Name, Department) VALUES (‘John’, ‘Sales’);”

A. All Correct
B. Employee ID
C. A WHERE clause
D. Additional column names

Shw me The Right Answer

Answer . A 

Q.4 Identify the error in
“UPDATE Employees SET Salary = Salary * 1.05 WHERE;”

A. UPDATE keyword
B. SET keyword
C. WHERE clause
D. No error

Shw me The Right Answer

Answer . C 

Q.5 In the query “SELECT Name FROM Employees WHERE Age > 30 AND Department = ‘HR’;”,
what needs to be corrected?

A. All Correct
B. The SELECT keyword
C. The WHERE clause
D. The AND operator

Shw me The Right Answer

Answer . A 

Q.6 How does a transaction ensure data integrity in SQL?

A. By locking the database
B. By allowing multiple users to modify data simultaneously
C. By ensuring all operations within the transaction are completed before committing
D. By automatically updating all related tables

Shw me The Right Answer

Answer . C 

Q.7 Which command is used to remove a specific record from a table in SQL?

A. DELETE
B. UPDATE
C. INSERT
D. SELECT

Shw me The Right Answer

Answer . A 

Q.8 In SQL, what is the purpose of the WHERE clause in a DELETE statement?

A. Specifies which database to use
B. Specifies which table to delete from
C. Specifies which records to delete
D. Specifies how to order the records

Shw me The Right Answer

Answer . C 

Q.9 What does the UPDATE command in SQL do?

A. Deletes a record
B. Modifies an existing record
C. Adds a new record
D. Retrieves data

Shw me The Right Answer

Answer . B 

Q.10 Which SQL command is used to add a new record to a table?

A. SELECT
B. DELETE
C. UPDATE
D. INSERT

Shw me The Right Answer

Answer . D 

Q.11 In “ALTER TABLE Students ADD COLUMN Email varchar(50),
what is missing for this statement to be correct?

A. ADD COLUMN
B. Email
C. varchar(50)
D. All Correct

Shw me The Right Answer

Answer . D 

Q.12 Correct the syntax error in
“CREATE TABLE Students (ID int PRIMARY, Name varchar(50));”

A. PRIMARY
B. ID int
C. Name varchar(50)
D. CREATE TABLE

Shw me The Right Answer

Answer . A 

Q.13 What needs to be changed in
“TRUNCATE Students;” to make it a valid SQL statement?

A. TRUNCATE
B. Students
C. All Correct
D. Add a WHERE clause

Shw me The Right Answer

Answer . C 

Q.14 Identify the error in
“ALTER TABLE Students DROP COLUMN DateOfBirth date;”

A. ALTER TABLE
B. DROP COLUMN
C. DateOfBirth
D. date

Shw me The Right Answer

Answer . D 

Q.15 Which part of this statement is incorrect?
“CREATE TABEL Students (ID int, Name varchar(50));”

A. TABEL
B. Students
C. ID int
D. Name varchar(50)

Shw me The Right Answer

Answer . A 

Q.16 What is the difference between the DROP and TRUNCATE commands in SQL?

A. DROP deletes the table, TRUNCATE deletes only the table data
B. TRUNCATE deletes the table, DROP deletes only the table data
C. No difference
D. Both commands modify table data

Shw me The Right Answer

Answer . A 

Q.17 Which command should be used to change the datatype of a column in an SQL table?

A. CREATE
B. ALTER
C. DROP
D. TRUNCATE

Shw me The Right Answer

Answer . B 

Q.18 In SQL, what is the purpose of the TRUNCATE command?

A. Deletes specific rows from a table
B. Removes all rows from a table
C. Changes table structure
D. Creates a new table

Shw me The Right Answer

Answer . B 

Q.19 What does the DROP command do in SQL?

A. Adds a new row to a table
B. Deletes an existing table
C. Modifies a table
D. Creates a new table

Shw me The Right Answer

Answer . B 

Q.20 Which SQL command is used to create a new table in a database?

A. CREATE
B. ALTER
C. DROP
D. TRUNCATE

Shw me The Right Answer

Answer . A 

Q.21 What data type would you use in SQL to store a date and time value together?

A. DATETIME
B. DATE
C. TIME
D. TIMESTAMP

Shw me The Right Answer

Answer . A 

Q.22 In SQL, what is the difference between CHAR and VARCHAR data types?

A. CHAR is fixed length, VARCHAR is variable length
B. CHAR is variable length, VARCHAR is fixed length
C. No difference
D. VARCHAR is used only for numeric data

Shw me The Right Answer

Answer . A 

Q.23 Which SQL data type is used to store numerical values with fixed precision and scale?

A. DECIMAL
B. INTEGER
C. DATE
D. VARCHAR

Shw me The Right Answer

Answer . A 

Q.24 In SQL, which data type is best suited for storing large texts such as articles or comments?

A. TEXT
B. VARCHAR
C. CHAR
D. BLOB

Shw me The Right Answer

Answer . A 

Q.25 Which data type is used in SQL to store true or false values?

A. INT
B. BOOLEAN
C. VARCHAR
D. FLOAT

Shw me The Right Answer

Answer . B 

Q.26 Which of the following is not a characteristic of a good database design?

A. Data integrity
B. Data redundancy
C. Scalability
D. Efficiency

Shw me The Right Answer

Answer . B 

Q.27 What is the purpose of normalization in a database?

A. Increase data redundancy
B. Optimize query speed
C. Reduce data redundancy
D. Improve data security

Shw me The Right Answer

Answer . C 

Q.28 Which SQL statement is used to retrieve data from a database?

A. UPDATE
B. DELETE
C. INSERT
D. SELECT

Shw me The Right Answer

Answer . D 

Q.29 In a database, what is a unique identifier for each record in a table called?

A. Primary key
B. Secondary key
C. Foreign key
D. Index key

Shw me The Right Answer

Answer . A 

Q.30 What type of database model organizes data in tables with rows and columns?

A. Hierarchical
B. Network
C. Relational
D. Object-Oriented

Shw me The Right Answer

Answer . C 

Q.31 Identify the error in
“SELECT * FROM Orders WHERE OrderDate >= ‘2023-01-01’ OR >= ‘2023-06-01’;”

A. OR operator
B. >= ‘2023-06-01’
C. No error
D. The date format

Shw me The Right Answer

Answer . B 

Q.32 What needs correction in
“SELECT * FROM Employees WHERE Salary = 5000 AND Department = ‘HR’;”?

A. All Correct
B. = in Salary
C. AND
D. = in Department

Shw me The Right Answer

Answer . A 

Q.33 In SQL, how does the compound operator ‘+=’ function?

A. Adds two values
B. Adds a value to a column’s existing value
C. Subtracts one value from another
D. Concatenates strings

Shw me The Right Answer

Answer . B 

Q.34 Which bitwise operator performs a logical AND operation on two expressions?

A. & (AND)
B. | (OR)
C. ^ (XOR)
D. ~ (NOT)

Shw me The Right Answer

Answer . A 

Q.35 What does the comparison operator ‘<>’ do in SQL?

A. Checks for equality
B. Checks for inequality
C. Checks if less than
D. Checks if greater than

Shw me The Right Answer

Answer . B 

Q.36 In SQL, what does the logical operator AND do when used in a WHERE clause?

A. Selects a record if either condition is true
B. Selects a record if both conditions are true
C. Negates a condition
D. None of the above

Shw me The Right Answer

Answer . B 

Q.37 Which arithmetic operator is used for division in SQL?

A. “-”
B. “*”
C. “/”
D. “+”

Shw me The Right Answer

Answer . C 

Q.38 Correct the error in
“CREATE TABLE Products (ProductID int, Price decimal CHECK Price > 0);”

A. CREATE TABLE
B. Price decimal
C. CHECK constraint usage
D. ProductID int

Shw me The Right Answer

Answer . C 

Q.39 What is missing in
“ALTER TABLE Employees ADD CHECK (Age >= 18);”?

A. ALTER TABLE
B. ADD CHECK
C. (Age >= 18)
D. All Correct

Shw me The Right Answer

Answer . D 

Q.40 Identify the issue in
“CREATE TABLE Orders (OrderID int, CustomerID int REFERENCES Customers);”

A. CREATE TABLE
B. OrderID int
C. CustomerID int
D. REFERENCES Customers

Shw me The Right Answer

Answer . D 

Q.41 In the statement
“CREATE TABLE Employees (ID int, Salary decimal DEFAULT 10000);”,
identify the error.

A. CREATE TABLE
B. ID int
C. Salary decimal
D. No Error

Shw me The Right Answer

Answer . D 

Q.42 Correct the syntax error in
“CREATE TABLE Students (ID int NOT);”

A. CREATE TABLE
B. Students
C. ID int
D. NOT

Shw me The Right Answer

Answer . D 

Q.43 What needs to be corrected in
“ALTER TABLE Employees ADD UNIQUE (EmployeeID, Name);”?

A. ALTER TABLE
B. ADD UNIQUE
C. (EmployeeID, Name)
D. All Correct

Shw me The Right Answer

Answer . D 

Q.44 Identify the error in
“CREATE TABLE Orders (OrderID int PRIMARY KEY, ProductID int FOREIGN);”

A. CREATE TABLE
B. PRIMARY KEY
C. FOREIGN
D. No error

Shw me The Right Answer

Answer . C 

Q.45 How does the DEFAULT constraint function in SQL?

A. It provides a default value for a column when no value is specified
B. It sets default permissions for users
C. It creates default tables
D. It sets default sorting for data

Shw me The Right Answer

Answer . A 

Q.46 Which constraint is used to define a condition that each row must satisfy in a SQL table?

A. DEFAULT
B. CHECK
C. PRIMARY KEY
D. UNIQUE

Shw me The Right Answer

Answer . B 

Q.47 What is the purpose of the FOREIGN KEY constraint?

A. To create a new table
B. To ensure unique values in a column
C. To establish a link between two tables
D. To validate data format

Shw me The Right Answer

Answer . C 

Q.48 What does the UNIQUE constraint in SQL do?

A. Prevents duplicate values in a column
B. Links two tables together
C. Automatically updates a column
D. Creates a new table

Shw me The Right Answer

Answer . A 

Q.49 Which constraint ensures that a column cannot have a NULL value?

A. PRIMARY KEY
B. FOREIGN KEY
C. UNIQUE
D. NOT NULL

Shw me The Right Answer

Answer . D 

Q.50 What is the primary role of a primary key in a database table?

A. To sort data
B. To identify unique records
C. To establish relationships with other tables
D. To check data integrity

Shw me The Right Answer

Answer . B 

Q.51 Correct the error in
“COMMIT WORK;”

A. COMMIT
B. WORK
C. No error
D. Semicolon

Shw me The Right Answer

Answer . C 

Q.52 Identify the issue in
“ROLLBACK TRANSACTION TO Savepoint1;”

A. ROLLBACK TRANSACTION
B. TO
C. Savepoint1
D. No issue

Shw me The Right Answer

Answer . D 

Q.53 In the statement “BEGIN TRANSACTION; UPDATE Employees SET Age = Age + 1; COMMIT;”,
what needs correction?

A. BEGIN TRANSACTION
B. UPDATE Employees
C. SET Age = Age + 1
D. All Correct

Shw me The Right Answer

Answer . D 

Q.54 How does a transaction in SQL ensure data consistency?

A. By locking the entire database
B. By allowing only one transaction at a time
C. By maintaining a log of all operations
D. By saving changes at regular intervals

Shw me The Right Answer

Answer . C 

Q.55 What does the ROLLBACK command do in a transaction?

A. Starts a new transaction
B. Saves the transaction changes
C. Restores the database to the state before the transaction started
D. Grants user permissions

Shw me The Right Answer

Answer . C 

Q.56 What is the purpose of the COMMIT command in SQL?

A. To start a transaction
B. To save changes made by a transaction
C. To undo changes made by a transaction
D. To revoke user permissions

Shw me The Right Answer

Answer . B 

Q.57 Identify the error in
“REVOKE INSERT, UPDATE ON Database FROM user123;”

A. REVOKE
B. INSERT, UPDATE
C. ON Database
D. FROM user123

Shw me The Right Answer

Answer . C 

Q.58 Which part of this statement is incorrect?
“GRANT SELECT ON Employees TO user123;”

A. GRANT
B. SELECT ON
C. Employees
D. All Correct

Shw me The Right Answer

Answer . D 

Q.59 What does the REVOKE command do in SQL?

A. Adds new user accounts
B. Removes specific access privileges from users
C. Deletes tables
D. Inserts data

Shw me The Right Answer

Answer . B 

Q.60 What is the primary purpose of the GRANT command in SQL?

A. To create a new table
B. To delete data from a table
C. To give users access privileges
D. To update table data

Shw me The Right Answer

Answer . C 

Q.61 What is the main characteristic of a FULL OUTER JOIN?

A. It combines all records from both tables when there are no matches
B. It only joins rows with matching values in both tables
C. It excludes all unmatched rows
D. It joins rows that satisfy a condition in either table

Shw me The Right Answer

Answer . A 

Q.62 What does an INNER JOIN do in SQL?

A. Joins rows that satisfy a condition in either table
B. Joins all rows from both tables
C. Joins rows with matching values in both tables
D. Joins rows that do not match in either table

Shw me The Right Answer

Answer . C 

Q.63 Identify the error in
“SELECT Name, Department FROM Employees UNION SELECT Name FROM Managers;”

A. The UNION keyword
B. The number of columns in SELECT statements
C. The table names
D. No error

Shw me The Right Answer

Answer . B 

Q.64 What needs to be corrected in
“SELECT Name FROM Employees UNION ALL SELECT Name FROM Managers;”?

A. All Correct
B. The UNION ALL keyword
C. The SELECT statement
D. The table names

Shw me The Right Answer

Answer . A 

Q.65 What is the main difference between UNION and UNION ALL in SQL?

A. UNION removes duplicates, UNION ALL does not
B. UNION ALL removes duplicates, UNION does not
C. No difference
D. UNION is faster than UNION ALL

Shw me The Right Answer

Answer . A 

Q.66 What is wrong in
“SELECT Department, COUNT(*) AS TotalEmployees FROM Employees GROUP BY Department HAVING TotalEmployees > 5 ORDER BY TotalEmployees;”?

A. SELECT Department
B. COUNT(*) AS TotalEmployees
C. HAVING clause misuse
D. ORDER BY TotalEmployees

Shw me The Right Answer

Answer . C 

Q.67 Correct the error in
“SELECT Name FROM Employees WHERE Department IN (SELECT Department FROM Departments WHERE Location = ‘New York’) ORDER BY Name GROUP BY Department;”

A. WHERE Department IN
B. ORDER BY Name
C. GROUP BY Department
D. No error

Shw me The Right Answer

Answer . C 

Q.68 In “SELECT Department, COUNT(EmployeeID) FROM Employees GROUP BY Department HAVING COUNT(EmployeeID) > ALL (SELECT COUNT(EmployeeID) FROM Employees GROUP BY Department);”
what needs correction?

A. The ALL operator
B. COUNT(EmployeeID)
C. No error
D. The subquery

Shw me The Right Answer

Answer . C 

Q.69 Identify the mistake in
“SELECT Department, MAX(Salary) FROM Employees WHERE MAX(Salary) > 50000 GROUP BY Department;”

A. SELECT Department
B. MAX(Salary)
C. WHERE MAX(Salary) > 50000
D. GROUP BY Department

Shw me The Right Answer

Answer . C 

Q.70 What is incorrect in
“SELECT * FROM Employees ORDER BY 3;”?

A. SELECT *
B. FROM Employees
C. ORDER BY 3
D. All Correct

Shw me The Right Answer

Answer . D 

Q.71 In “SELECT Department, SUM(Salary) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;”,
identify the error.

A. SELECT Department
B. SUM(Salary)
C. GROUP BY Department
D. No Error

Shw me The Right Answer

Answer . D 

Q.72 Correct the syntax error in
“SELECT Name, Department, COUNT(*) FROM Employees WHERE Department = ‘Sales’ GROUP BY Department;”

A. SELECT Name
B. Department
C. COUNT(*)
D. WHERE Department = ‘Sales’

Shw me The Right Answer

Answer . A 

Q.73 What needs to be corrected in
“SELECT AVG(Salary) AS AverageSalary FROM Employees HAVING AverageSalary > 50000;”?

A. SELECT AVG(Salary)
B. AS AverageSalary
C. FROM Employees
D. HAVING AverageSalary > 50000

Shw me The Right Answer

Answer . D 

Q.74 Identify the error in
“SELECT Department, COUNT(*) FROM Employees GROUP BY Salary;”

A. SELECT Department
B. COUNT(*)
C. GROUP BY Salary
D. No error

Shw me The Right Answer

Answer . C 

Q.75 What is incorrect in
“SELECT Name FROM Employees WHERE Department = ‘Sales’ ORDER BY Age;”?

A. SELECT Name
B. WHERE Department = ‘Sales’
C. ORDER BY Age
D. All Correct

Shw me The Right Answer

Answer . D 

Q.76 In SQL, can the HAVING clause be used without an aggregate function?

A. Yes, it acts like a WHERE clause
B. No, it must be used with an aggregate function
C. Yes, but it has no effect
D. No, it causes an error

Shw me The Right Answer

Answer . A 

Q.77 What is the effect of combining GROUP BY with ORDER BY in an SQL query?

A. GROUP BY overrides ORDER BY
B. ORDER BY overrides GROUP BY
C. They can be used together for organized grouping and sorting
D. They cannot be used together in the same query

Shw me The Right Answer

Answer . C 

Q.78 Can the ORDER BY clause use column aliases defined in the SELECT statement?

A. Yes
B. No
C. Only if they are numerical
D. Only in subqueries

Shw me The Right Answer

Answer . A 

Q.79 What happens if you use a column in the SELECT statement that is not in the GROUP BY clause?

A. The query fails
B. The query succeeds, and the column shows arbitrary values
C. The query is automatically corrected
D. The column is ignored

Shw me The Right Answer

Answer . A 

Q.80 How does the ORDER BY clause treat NULL values by default?

A. It places them at the beginning of the result set
B. It places them at the end of the result set
C. It ignores them
D. It causes an error

Shw me The Right Answer

Answer . B 

Q.81 In an SQL query, what role does HAVING play without a GROUP BY clause?

A. It functions as a WHERE clause
B. It has no effect
C. It causes an error
D. It filters aggregated results

Shw me The Right Answer

Answer . A 

Q.82 What is the main difference between WHERE and HAVING clauses in SQL?

A. WHERE filters rows before grouping, HAVING filters rows after grouping
B. HAVING filters rows before grouping, WHERE filters rows after grouping
C. No difference
D. WHERE is used with aggregate functions, HAVING is not

Shw me The Right Answer

Answer . A 

Q.83 In SQL, how does the GROUP BY clause function when combined with an aggregate function like SUM or COUNT?

A. It calculates the aggregate for the entire table
B. It groups rows based on unique values in a column and calculates the aggregate for each group
C. It filters the rows before aggregation
D. It sorts the result set

Shw me The Right Answer

Answer . B 

Q.84 What is the purpose of the ORDER BY clause in SQL?

A. Filters rows
B. Sorts the result set
C. Groups rows
D. Joins tables

Shw me The Right Answer

Answer . B 

Q.85 What does the WHERE clause do in an SQL query?

A. Sorts the result set
B. Filters rows before grouping
C. Joins tables
D. Filters rows after grouping

Shw me The Right Answer

Answer . B 

Q.86 What needs to be changed in
“UPDATE Employees SET Salary *= 2 WHERE YearsOfExperience > 5;”?

A. *= 2
B. WHERE
C. YearsOfExperience > 5
D. All Correct

Shw me The Right Answer

Answer . D 

Q.87 Identify the mistake in
“SELECT * FROM Employees WHERE Department = ‘HR’ XOR Department = ‘Finance’;”

A. XOR operator
B. = ‘HR’
C. = ‘Finance’
D. No mistake, the statement is correct

Shw me The Right Answer

Answer . A 

Q.88 In “SELECT Name FROM Employees WHERE NOT (Age < 30 AND Department = ‘Sales’);”,
identify the error.

A. NOT operator
B. < 30
C. AND
D. No error

Shw me The Right Answer

Answer . D 

Q.89 What is incorrect in
“SELECT EmployeeID, Salary FROM Employees WHERE Salary BETWEEN 30000 AND 50000;”?

A. SELECT
B. EmployeeID, Salary
C. BETWEEN
D. All Correct

Shw me The Right Answer

Answer . D 

Q.90 Correct the syntax error in
“UPDATE Products SET Price = Price * 1.1 WHERE Price < 100 OR Price > 200;”

A. * 1.1
B. WHERE
C. OR
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.91 What needs to be corrected in
“SELECT COALESCE(Salary, 0) FROM Employees;”?

A. All Correct
B. COALESCE
C. Salary
D. 0

Shw me The Right Answer

Answer . A 

Q.92 What does the COALESCE function do in SQL?

A. Returns the first non-null value in a list
B. Combines multiple rows into a single string
C. Duplicates a string
D. Compares two expressions and returns NULL if they are equal

Shw me The Right Answer

Answer . A 

Q.93 Correct the syntax error in
“SELECT Name, TRY_CONVERT(INT, Age) AS IntegerAge FROM Employees WHERE Age IS NOT NULL;”

A. TRY_CONVERT function
B. INT keyword
C. Age column
D. No Error

Shw me The Right Answer

Answer . D 

Q.94 Identify the error in
“SELECT CONVERT(VARCHAR, StartDate, 103) FROM Projects WHERE StartDate IS NOT NULL;”

A. CONVERT function
B. VARCHAR keyword
C. StartDate column
D. No Error

Shw me The Right Answer

Answer . D 

Q.95 What needs to be corrected in
“SELECT CAST(Salary AS INT) FROM Employees;”?

A. All Correct
B. CAST
C. Salary
D. AS INT

Shw me The Right Answer

Answer . A 

Q.96 In “SELECT SQUARE(Length) FROM Rectangles;”,
what needs correction?

A. SQUARE
B. Length
C. No error
D. FROM Rectangles

Shw me The Right Answer

Answer . C 

Q.97 What is incorrect in
“SELECT Name, PI() * Radius * Radius AS Area FROM Circles;”?

A. PI()
B. Radius * Radius
C. AS Area
D. All Correct

Shw me The Right Answer

Answer . D 

Q.98 Correct the syntax error in
“SELECT CEILING(Price) AS RoundedPrice FROM Products WHERE Price > 0;”

A. CEILING
B. RoundedPrice
C. FROM Products
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.99 Identify the error in
“SELECT Name, SQRT(Age) FROM Employees WHERE Age >= 0;”

A. SELECT Name
B. SQRT
C. Age >= 0
D. No error

Shw me The Right Answer

Answer . D 

Q.100 What needs to be corrected in
“SELECT ROUND(Salary, 2) FROM Employees;”?

A. All Correct
B. ROUND
C. Salary
D. 2

Shw me The Right Answer

Answer . A 

Q.101 How does the SQUARE function differ from the POWER function in SQL?

A. SQUARE calculates the square, POWER calculates any exponent
B. SQUARE and POWER are the same
C. SQUARE calculates the square root, POWER calculates the square
D. SQUARE calculates any exponent, POWER calculates the square

Shw me The Right Answer

Answer . A 

Q.102 What is the purpose of the PI function in SQL?

A. To return the value of PI
B. To calculate the perimeter of a circle
C. To calculate the area of a circle
D. To return the radius of a circle

Shw me The Right Answer

Answer . A 

Q.103 In SQL, what is the result of the SQRT function when applied to a negative number?

A. A positive number
B. Zero
C. An error
D. A negative number

Shw me The Right Answer

Answer . C 

Q.104 What does the CEILING function do in SQL?

A. Returns the smallest integer greater than or equal to a given number
B. Returns the largest integer less than or equal to a given number
C. Calculates the square of a number
D. Calculates the square root of a number

Shw me The Right Answer

Answer . A 

Q.105 What is the purpose of the ROUND function in SQL?

A. To round a number to the nearest integer
B. To round a number to a specified number of decimal places
C. To find the square root of a number
D. To return the value of PI

Shw me The Right Answer

Answer . B 

Q.106 What is wrong in
“SELECT * FROM Employees FULL OUTER JOIN
Departments ON Employees.
DepartmentID = Departments.DepartmentID WHERE Departments.
DepartmentName IS NULL;”?

A. FULL OUTER JOIN
B. ON clause
C. WHERE clause
D. All Correct

Shw me The Right Answer

Answer . D 

Q.107 In “SELECT * FROM Employees CROSS JOIN Departments;”,
what needs correction?

A. CROSS JOIN
B. No error
C. The SELECT statement
D. The table names

Shw me The Right Answer

Answer . B 

Q.108 Identify the issue in
“SELECT E.Name, D.Name FROM Employees E JOIN Departments D ON E.DepartmentID > D.DepartmentID;”

A. JOIN keyword
B. > operator
C. No error
D. The ON clause

Shw me The Right Answer

Answer . B 

Q.109 Correct the syntax error in
“SELECT * FROM Employees A LEFT JOIN Departments B ON A.DepartmentID == B.DepartmentID;”

A. LEFT JOIN
B. ON clause
C. No syntax error
D. == operator

Shw me The Right Answer

Answer . D 

Q.110 What needs to be changed in
“SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID <> Customers.ID;”?

A. INNER JOIN
B. <> operator
C. No change
D. The ON clause

Shw me The Right Answer

Answer . B 

Q.111 In “SELECT * FROM Orders FULL JOIN Customers ON Orders.CustomerID = Customers.ID;”,
identify the error.

A. The FULL JOIN keyword
B. ON clause
C. No error
D. The table names

Shw me The Right Answer

Answer . C 

Q.112 What is incorrect in
“SELECT A.Name, B.Name FROM Employees A, Employees B WHERE A.EmployeeID < B.EmployeeID;”?

A. The SELECT statement
B. The WHERE clause
C. No error, it is a SELF JOIN
D. The table aliases (A, B)

Shw me The Right Answer

Answer . C 

Q.113 Correct the syntax error in
“SELECT * FROM Orders RIGHT OUTER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Orders.OrderDate = ‘2023-01-01’;”

A. RIGHT OUTER JOIN
B. ON clause
C. WHERE clause
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.114 Identify the error in
“SELECT Employees.Name, Departments.Name FROM Employees LEFT JOIN Departments USING (DepartmentID);”

A. The LEFT JOIN
B. USING (DepartmentID)
C. No error
D. The SELECT statement

Shw me The Right Answer

Answer . C 

Q.115 What needs to be corrected in
“SELECT * FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;”?

A. All Correct
B. INNER JOIN
C. ON clause
D. Table names

Shw me The Right Answer

Answer . A 

Q.116 How does a NON-EQUI JOIN differ from an EQUI JOIN?

A. NON-EQUI JOIN uses non-equality operators, EQUI JOIN uses equality operators
B. NON-EQUI JOIN is faster than EQUI JOIN
C. NON-EQUI JOIN cannot be used with WHERE clause, EQUI JOIN can
D. There is no difference

Shw me The Right Answer

Answer . A 

Q.117 In a RIGHT JOIN, what happens to the rows from the right table that have no matches in the left table?

A. They are included in the result set with NULLs in the columns of the left table
B. They are excluded from the result set
C. They are included as duplicates
D. They are replaced with values from the left table

Shw me The Right Answer

Answer . A 

Q.118 What is an EQUI JOIN?

A. A join using an equality operator
B. A join using any comparison operator other than equality
C. A join based on the equidistant principle
D. A join that always produces an equal number of rows from both tables

Shw me The Right Answer

Answer . A 

Q.119 In SQL, what does a SELF JOIN refer to?

A. Joining a table with a different table
B. Joining a table with itself using a different alias
C. Joining a table with a copy of itself
D. Joining a table with its foreign key

Shw me The Right Answer

Answer . B 

Q.120 What is a LEFT JOIN in SQL?

A. A join that retrieves records from the left table only
B. A join that retrieves records from the right table only
C. A join that retrieves all records from the left table and matched records from the right table
D. A join that retrieves matched records from both tables

Shw me The Right Answer

Answer . C 

Q.121 What needs to be corrected in
“CREATE OR REPLACE VIEW DepartmentSummary AS SELECT DepartmentID, COUNT(*) FROM Employees GROUP BY DepartmentID;”?

A. CREATE OR REPLACE VIEW
B. DepartmentSummary
C. SELECT DepartmentID, COUNT(*)
D. No error

Shw me The Right Answer

Answer . D 

Q.122 Identify the error in
“CREATE VIEW ActiveEmployees AS SELECT * FROM Employees WHERE Status = ‘Active’;”

A. CREATE VIEW
B. ActiveEmployees
C. SELECT * FROM Employees
D. No error

Shw me The Right Answer

Answer . D 

Q.123 What is a materialized view in SQL?

A. A view that is automatically updated when the underlying tables change
B. A view that is created for temporary use only
C. A view that is stored physically on the disk
D. A view that can be indexed

Shw me The Right Answer

Answer . C 

Q.124 What is a view in SQL?

A. A physical table stored in the database
B. A temporary table created during a session
C. A virtual table based on the result-set of an SQL statement
D. A duplicate copy of another table

Shw me The Right Answer

Answer . C 

Q.125 Correct the syntax error in
“SELECT Name, (SELECT MAX(Salary) FROM Employees) AS MaxSalary FROM Employees WHERE DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = ‘HR’);”

A. (SELECT MAX(Salary) FROM Employees)
B. AS MaxSalary
C. WHERE DepartmentID
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.126 What needs to be corrected in
“SELECT Name FROM Employees WHERE EXISTS (SELECT * FROM Departments WHERE Employees.DepartmentID = Departments.DepartmentID);”?

A. EXISTS clause
B. SELECT *
C. FROM Departments
D. No error

Shw me The Right Answer

Answer . D 

Q.127 Identify the error in
“SELECT Name FROM Employees WHERE Salary > (SELECT AVG(Salary) FROM Employees);”

A. SELECT Name
B. WHERE Salary
C. (SELECT AVG(Salary) FROM Employees)
D. No error

Shw me The Right Answer

Answer . D 

Q.128 What is a correlated subquery in SQL?

A. A subquery that can be executed independently of the outer query
B. A subquery that uses values from the outer query
C. A subquery that returns multiple columns
D. A subquery used in the FROM clause

Shw me The Right Answer

Answer . B 

Q.129 In “SELECT Name, LTRIM(RTRIM(Name)) AS TrimmedName FROM Customers;”,
what needs correction?

A. LTRIM
B. RTRIM
C. Name
D. No error

Shw me The Right Answer

Answer . D 

Q.130 What is incorrect in
“SELECT UPPER(Name) FROM Employees;”?

A. UPPER
B. Name
C. FROM Employees
D. All Correct

Shw me The Right Answer

Answer . D 

Q.131 Correct the syntax error in
“SELECT Name, CHARINDEX(‘a’, Name) FROM Employees WHERE Name IS NOT NULL;”

A. CHARINDEX
B. ‘a’, Name
C. FROM Employees
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.132 Identify the error in
“SELECT SUBSTRING(Name, 1, 3) AS ShortName FROM Products;”

A. SUBSTRING
B. Name, 1, 3
C. AS ShortName
D. No error

Shw me The Right Answer

Answer . D 

Q.133 What needs to be corrected in
“SELECT CONCAT(FirstName, ‘ ‘, LastName) FROM Employees;”?

A. All Correct
B. CONCAT
C. FirstName
D. LastName

Shw me The Right Answer

Answer . A 

Q.134 In “SELECT Name, LOG(Salary, 10) AS LogSalary FROM Employees WHERE Salary > 0;”,
what needs correction?

A. LOG
B. Salary, 10
C. AS LogSalary
D. No error

Shw me The Right Answer

Answer . D 

Q.135 What is incorrect in
“SELECT MAX(Salary) – MIN(Salary) AS SalaryRange FROM Employees;”?

A. MAX(Salary)
B. MIN(Salary)
C. AS SalaryRange
D. All Correct

Shw me The Right Answer

Answer . D 

Q.136 Correct the syntax error in
“SELECT Name, ROUND(Salary, -2) FROM Employees;”

A. ROUND
B. Salary, -2
C. FROM Employees
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.137 Identify the error in
“SELECT Name, CEILING(Salary) FROM Employees WHERE Salary > 0;”

A. CEILING
B. Salary
C. WHERE Salary > 0
D. No error

Shw me The Right Answer

Answer . D 

Q.138 What needs to be corrected in
“SELECT ABS(-123) FROM Dual;”?

A. All Correct
B. ABS
C. -123
D. FROM Dual

Shw me The Right Answer

Answer . A 

Q.139 In “SELECT Name, AGE(BirthDate) AS Age FROM Customers;”,
what needs correction?

A. AGE
B. BirthDate
C. AS Age
D. No error

Shw me The Right Answer

Answer . A 

Q.140 What is incorrect in
“SELECT EXTRACT(MONTH FROM OrderDate) AS OrderMonth FROM Orders;”?

A. EXTRACT
B. MONTH FROM
C. OrderDate
D. All Correct

Shw me The Right Answer

Answer . D 

Q.141 Correct the syntax error in
“SELECT Name, DATEADD(MONTH, 6, HireDate) FROM Employees;”

A. DATEADD
B. MONTH
C. 6
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.142 Identify the error in
“SELECT Name, DATEDIFF(year, HireDate, GETDATE()) AS YearsWorked FROM Employees;”

A. DATEDIFF
B. year
C. HireDate
D. No error

Shw me The Right Answer

Answer . D 

Q.143 What needs to be corrected in
“SELECT CURRENT_DATE FROM Employees;”?

A. All Correct
B. CURRENT_DATE
C. FROM Employees
D. The entire query

Shw me The Right Answer

Answer . A 

Q.144 Identify the error in
“SELECT Name, CASE Gender WHEN ‘M’ THEN ‘Male’ WHEN ‘F’ THEN ‘Female’ END AS Gender FROM Employees;”

A. CASE Gender
B. WHEN ‘M’ THEN ‘Male’
C. WHEN ‘F’ THEN ‘Female’
D. No error

Shw me The Right Answer

Answer . D 

Q.145 What needs to be corrected in
“SELECT Name, CASE WHEN Age >= 18 THEN ‘Adult’ ELSE ‘Minor’ END FROM Employees;”?

A. All Correct
B. CASE WHEN
C. THEN ‘Adult’
D. ELSE ‘Minor’

Shw me The Right Answer

Answer . A 

Q.146 What is the main use of the CASE statement in SQL?

A. To execute a sequence of commands
B. To handle errors
C. To perform if-then-else type logic
D. To loop through records

Shw me The Right Answer

Answer . C 

Q.147 In “SELECT Name, NVL2(Salary, Salary * 1.1, Salary) AS NewSalary FROM Employees;”,
what needs correction?

A. NVL2
B. Salary * 1.1
C. Salary
D. No error

Shw me The Right Answer

Answer . D 

Q.148 What is incorrect in
“SELECT COALESCE(FirstName, LastName, ‘Unknown’) FROM Authors;”?

A. COALESCE
B. FirstName
C. LastName
D. All Correct

Shw me The Right Answer

Answer . D 

Q.149 Correct the syntax error in
“SELECT NVL(Salary, ‘Not Provided’) FROM Contractors;”

A. NVL
B. Salary
C. ‘Not Provided’
D. No syntax error

Shw me The Right Answer

Answer . D 

Q.150 Identify the error in
“SELECT Name, NULLIF(Age, 30) FROM Employees WHERE Age IS NOT NULL;”

A. NULLIF
B. Age
C. 30
D. No error

Shw me The Right Answer

Answer . D 

Q.151 Identify the error in “UPDATE Employees SET Age = Age + 1 WHERE Department IN (‘Sales’, ‘HR’) AND Age >= 30;”

A. Change ‘Age = Age + 1’ to ‘Age = Age – 1’
B. Replace ‘IN’ with ‘NOT IN’
C. Remove ‘AND Age >= 30’
D. No error

Shw me The Right Answer

Answer . B 

Q.152 Correct the syntax error in
“DELETE FROM Employees HAVING Age < 25;”

A. DELETE keyword
B. FROM keyword
C. HAVING keyword
D. No syntax error

Shw me The Right Answer

Answer . C 

Q.153 What is missing in “INSERT INTO Employees (Name, Department) VALUES (‘John’, ‘Sales’);”

A. Add a closing parenthesis after ‘Sales’
B. Remove the opening parenthesis before ‘Name’
C. Include ‘ID’ column in the INSERT statement
D. No error

Shw me The Right Answer

Answer . C 

Q.154 Identify the error in
“UPDATE Employees SET Salary = Salary * 1.05 WHERE;”

A. UPDATE keyword
B. SET keyword
C. WHERE clause
D. No error

Shw me The Right Answer

Answer . C 

Q.155 What needs to be corrected in the query “SELECT Name FROM Employees WHERE Age > 30 AND Department = ‘HR’;”?

A. Replace ‘AND’ with ‘OR’
B. Change ‘Age > 30’ to ‘Age < 30’
C. Change ‘Department = ‘HR” to ‘Department == ‘HR”
D. No error

Shw me The Right Answer

Answer . C 

Q.156 How does a transaction ensure data integrity in SQL?

A. By locking the database
B. By allowing multiple users to modify data simultaneously
C. By ensuring all operations within the transaction are completed before committing
D. By automatically updating all related tables

Shw me The Right Answer

Answer . C 

Q.157 Which command is used to remove a specific record from a table in SQL?

A. DELETE
B. UPDATE
C. INSERT
D. SELECT

Shw me The Right Answer

Answer . A 

Q.158 In SQL, what is the purpose of the WHERE clause in a DELETE statement?

A. Specifies which database to use
B. Specifies which table to delete from
C. Specifies which records to delete
D. Specifies how to order the records

Shw me The Right Answer

Answer . C 

Q.159 What does the UPDATE command in SQL do?

A. Deletes a record
B. Modifies an existing record
C. Adds a new record
D. Retrieves data

Shw me The Right Answer

Answer . B 

Q.160 Which SQL command is used to add a new record to a table?

A. SELECT
B. DELETE
C. UPDATE
D. INSERT

Shw me The Right Answer

Answer . D 

Q.161 Identify the error in “ALTER TABLE Students ADD COLUMN Email varchar(50);”

A. Add ‘COLUMN’ after ‘ADD’
B. Change ‘varchar(50)’ to ‘varchar2(50)’
C. Change ‘Email’ to ‘EmailID’
D. No error

Shw me The Right Answer

Answer . A 

Q.162 Correct the syntax error in
“CREATE TABLE Students (ID int PRIMARY, Name varchar(50));”

A. PRIMARY
B. ID int
C. Name varchar(50)
D. CREATE TABLE

Shw me The Right Answer

Answer . A 

Q.163 What needs to be changed in ‘TRUNCATE TABLE Students;’ to make it a valid SQL statement?

A. Change ‘TRUNCATE’ to ‘DELETE’
B. Remove ‘TABLE’
C. Change ‘Students’ to ‘Student’
D. No error

Shw me The Right Answer

Answer . B 

Q.164 Identify the error in
“ALTER TABLE Students DROP COLUMN DateOfBirth date;”

A. ALTER TABLE
B. DROP COLUMN
C. DateOfBirth
D. date

Shw me The Right Answer

Answer . D 

Q.165 Which part of this statement is incorrect?
“CREATE TABEL Students (ID int, Name varchar(50));”

A. TABEL
B. Students
C. ID int
D. Name varchar(50)

Shw me The Right Answer

Answer . A 

Q.166 What is the difference between the DROP and TRUNCATE commands in SQL?

A. DROP deletes the table, TRUNCATE deletes only the table data
B. TRUNCATE deletes the table, DROP deletes only the table data
C. No difference
D. Both commands modify table data

Shw me The Right Answer

Answer . A 

Q.167 Which command should be used to change the datatype of a column in an SQL table?

A. CREATE
B. ALTER
C. DROP
D. TRUNCATE

Shw me The Right Answer

Answer . B 

Q.168 In SQL, what is the purpose of the TRUNCATE command?

A. Deletes specific rows from a table
B. Removes all rows from a table
C. Changes table structure
D. Creates a new table

Shw me The Right Answer

Answer . B 

Q.169 What does the DROP command do in SQL?

A. Adds a new row to a table
B. Deletes an existing table
C. Modifies a table
D. Creates a new table

Shw me The Right Answer

Answer . B 

Q.170 Which SQL command is used to create a new table in a database?

A. CREATE
B. ALTER
C. DROP
D. TRUNCATE

Shw me The Right Answer

Answer . A 

Q.171 What data type would you use in SQL to store a date and time value together?

A. DATETIME
B. DATE
C. TIME
D. TIMESTAMP

Shw me The Right Answer

Answer . A 

Q.172 In SQL, what is the difference between CHAR and VARCHAR data types?

A. CHAR is fixed length, VARCHAR is variable length
B. CHAR is variable length, VARCHAR is fixed length
C. No difference
D. VARCHAR is used only for numeric data

Shw me The Right Answer

Answer . A 

Q.173 Which SQL data type is used to store numerical values with fixed precision and scale?

A. DECIMAL
B. INTEGER
C. DATE
D. VARCHAR

Shw me The Right Answer

Answer . A 

Q.174 In SQL, which data type is best suited for storing large texts such as articles or comments?

A. TEXT
B. VARCHAR
C. CHAR
D. BLOB

Shw me The Right Answer

Answer . A 

Q.175 Which data type is used in SQL to store true or false values?

A. INT
B. BOOLEAN
C. VARCHAR
D. FLOAT

Shw me The Right Answer

Answer . B 

Q.176 Which of the following is not a characteristic of a good database design?

A. Data integrity
B. Data redundancy
C. Scalability
D. Efficiency

Shw me The Right Answer

Answer . B 

Q.177 What is the purpose of normalization in a database?

A. Increase data redundancy
B. Optimize query speed
C. Reduce data redundancy
D. Improve data security

Shw me The Right Answer

Answer . C 

Q.178 Which SQL statement is used to retrieve data from a database?

A. UPDATE
B. DELETE
C. INSERT
D. SELECT

Shw me The Right Answer

Answer . D 

Q.179 In a database, what is a unique identifier for each record in a table called?

A. Primary key
B. Secondary key
C. Foreign key
D. Index key

Shw me The Right Answer

Answer . A 

Q.180 What type of database model organizes data in tables with rows and columns?

A. Hierarchical
B. Network
C. Relational
D. Object-Oriented

Shw me The Right Answer

Answer . C 

Q.181 Identify the error in
“SELECT * FROM Orders WHERE OrderDate >= ‘2023-01-01’ OR >= ‘2023-06-01’;”

A. OR operator
B. >= ‘2023-06-01’
C. No error
D. The date format

Shw me The Right Answer

Answer . B 

Q.182 What needs correction in “SELECT * FROM Employees WHERE Salary = 5000 AND Department = ‘HR’;”?

A. Replace ‘*’ with ‘Name, Salary’
B. Change ‘=’ to ‘!=’ in ‘Salary = 5000’
C. Replace ‘AND’ with ‘OR’
D. No error

Shw me The Right Answer

Answer . C 

Q.183 In SQL, how does the compound operator ‘+=’ function?

A. Adds two values
B. Adds a value to a column’s existing value
C. Subtracts one value from another
D. Concatenates strings

Shw me The Right Answer

Answer . B 

Q.184 Which bitwise operator performs a logical AND operation on two expressions?

A. & (AND)
B. | (OR)
C. ^ (XOR)
D. ~ (NOT)

Shw me The Right Answer

Answer . A 

Q.185 What does the comparison operator ‘<>’ do in SQL?

A. Checks for equality
B. Checks for inequality
C. Checks if less than
D. Checks if greater than

Shw me The Right Answer

Answer . B 

Q.186 In SQL, what does the logical operator AND do when used in a WHERE clause?

A. Selects a record if either condition is true
B. Selects a record if both conditions are true
C. Negates a condition
D. None of the above

Shw me The Right Answer

Answer . B 

Q.187 Which arithmetic operator is used for division in SQL?

A. “-”
B. “*”
C. “/”
D. “+”

Shw me The Right Answer

Answer . C 

Q.188 Correct the error in
“CREATE TABLE Products (ProductID int, Price decimal CHECK Price > 0);”

A. CREATE TABLE
B. Price decimal
C. CHECK constraint usage
D. ProductID int

Shw me The Right Answer

Answer . C 

Q.189 What is missing in “ALTER TABLE Employees ADD CHECK (Age >= 18);”?

A. Add ‘CONSTRAINT’
B. Change ‘Age >= 18’ to ‘Age > 18’
C. Include column name before ‘CHECK’
D. No error

Shw me The Right Answer

Answer . A 

Q.190 Identify the issue in
“CREATE TABLE Orders (OrderID int, CustomerID int REFERENCES Customers);”

A. CREATE TABLE
B. OrderID int
C. CustomerID int
D. REFERENCES Customers

Shw me The Right Answer

Answer . D 

Q.191 In the statement “CREATE TABLE Employees (ID int, Salary decimal DEFAULT 10000);”, identify the error.

A. Change ‘int’ to ‘integer’
B. Remove ‘DEFAULT 10000’
C. Replace ‘decimal’ with ‘number’
D. No error

Shw me The Right Answer

Answer . B 

Q.192 Correct the syntax error in
“CREATE TABLE Students (ID int NOT);”

A. CREATE TABLE
B. Students
C. ID int
D. NOT

Shw me The Right Answer

Answer . D 

Q.193 What needs to be corrected in “ALTER TABLE Employees ADD UNIQUE (EmployeeID, Name);”?

A. Change ‘ADD’ to ‘CREATE’
B. Remove ‘UNIQUE’
C. Replace ‘(EmployeeID, Name)’ with ‘EmployeeID, Name’
D. No error

Shw me The Right Answer

Answer . B 

Q.194 Identify the error in
“CREATE TABLE Orders (OrderID int PRIMARY KEY, ProductID int FOREIGN);”

A. CREATE TABLE
B. PRIMARY KEY
C. FOREIGN
D. No error

Shw me The Right Answer

Answer . C 

Q.195 How does the DEFAULT constraint function in SQL?

A. It provides a default value for a column when no value is specified
B. It sets default permissions for users
C. It creates default tables
D. It sets default sorting for data

Shw me The Right Answer

Answer . A 

Q.196 Which constraint is used to define a condition that each row must satisfy in a SQL table?

A. DEFAULT
B. CHECK
C. PRIMARY KEY
D. UNIQUE

Shw me The Right Answer

Answer . B 

Q.197 What is the purpose of the FOREIGN KEY constraint?

A. To create a new table
B. To ensure unique values in a column
C. To establish a link between two tables
D. To validate data format

Shw me The Right Answer

Answer . C 

Q.198 What does the UNIQUE constraint in SQL do?

A. Prevents duplicate values in a column
B. Links two tables together
C. Automatically updates a column
D. Creates a new table

Shw me The Right Answer

Answer . A 

Q.199 Which constraint ensures that a column cannot have a NULL value?

A. PRIMARY KEY
B. FOREIGN KEY
C. UNIQUE
D. NOT NULL

Shw me The Right Answer

Answer . D 

Q.200 What is the primary role of a primary key in a database table?

A. To sort data
B. To identify unique records
C. To establish relationships with other tables
D. To check data integrity

Shw me The Right Answer

Answer . B 

Q.201 Correct the error in “COMMIT WORK;”

A. Change ‘COMMIT’ to ‘FINISH’
B. Replace ‘WORK’ with ‘TRANSACTION’
C. Add ‘TRANSACTION’ after ‘COMMIT’
D. No error

Shw me The Right Answer

Answer . C 

Q.202 Identify the issue in “ROLLBACK TRANSACTION TO Savepoint1;”

A. Change ‘ROLLBACK’ to ‘REVERT’
B. Remove ‘TO’
C. Replace ‘Savepoint1’ with ‘SAVEPOINT1’
D. No error

Shw me The Right Answer

Answer . B 

Q.203 In the statement “BEGIN TRANSACTION; UPDATE Employees SET Age = Age + 1; COMMIT;”, what needs correction?

A. Remove ‘BEGIN TRANSACTION’
B. Replace ‘COMMIT’ with ‘END TRANSACTION’
C. Change ‘SET Age = Age + 1’ to ‘SET Age = Age – 1’
D. No error

Shw me The Right Answer

Answer . B 

Q.204 How does a transaction in SQL ensure data consistency?

A. By locking the entire database
B. By allowing only one transaction at a time
C. By maintaining a log of all operations
D. By saving changes at regular intervals

Shw me The Right Answer

Answer . C 

Q.205 What does the ROLLBACK command do in a transaction?

A. Starts a new transaction
B. Saves the transaction changes
C. Restores the database to the state before the transaction started
D. Grants user permissions

Shw me The Right Answer

Answer . C 

Q.206 What is the purpose of the COMMIT command in SQL?

A. To start a transaction
B. To save changes made by a transaction
C. To undo changes made by a transaction
D. To revoke user permissions

Shw me The Right Answer

Answer . B 

Q.207 Identify the error in
“REVOKE INSERT, UPDATE ON Database FROM user123;”

A. REVOKE
B. INSERT, UPDATE
C. ON Database
D. FROM user123

Shw me The Right Answer

Answer . C 

Q.208 Which part of this statement is incorrect? “GRANT SELECT ON Employees TO user123;”

A. Change ‘GRANT’ to ‘GIVE’
B. Replace ‘SELECT ON’ with ‘SELECT FROM’
C. Change ‘user123’ to ‘User:123’
D. No error

Shw me The Right Answer

Answer . B 

Q.209 What does the REVOKE command do in SQL?

A. Adds new user accounts
B. Removes specific access privileges from users
C. Deletes tables
D. Inserts data

Shw me The Right Answer

Answer . B 

Q.210 What is the primary purpose of the GRANT command in SQL?

A. To create a new table
B. To delete data from a table
C. To give users access privileges
D. To update table data

Shw me The Right Answer

Answer . C 

Q.211 What is the main characteristic of a FULL OUTER JOIN?

A. It combines all records from both tables when there are no matches
B. It only joins rows with matching values in both tables
C. It excludes all unmatched rows
D. It joins rows that satisfy a condition in either table

Shw me The Right Answer

Answer . A 

Q.212 What does an INNER JOIN do in SQL?

A. Joins rows that satisfy a condition in either table
B. Joins all rows from both tables
C. Joins rows with matching values in both tables
D. Joins rows that do not match in either table

Shw me The Right Answer

Answer . C 

Q.213 Identify the error in
“SELECT Name, Department FROM Employees UNION SELECT Name FROM Managers;”

A. The UNION keyword
B. The number of columns in SELECT statements
C. The table names
D. No error

Shw me The Right Answer

Answer . B 

Q.214 What needs to be corrected in “SELECT Name FROM Employees UNION ALL SELECT Name FROM Managers;”?

A. Change ‘UNION ALL’ to ‘UNION’
B. Replace first ‘SELECT Name’ with ‘SELECT EmployeeName’
C. Add ‘WHERE’ clause to both SELECT statements
D. No error

Shw me The Right Answer

Answer . A 

Q.215 What is the main difference between UNION and UNION ALL in SQL?

A. UNION removes duplicates, UNION ALL does not
B. UNION ALL removes duplicates, UNION does not
C. No difference
D. UNION is faster than UNION ALL

Shw me The Right Answer

Answer . A 

Q.216 What is wrong in
“SELECT Department, COUNT(*) AS TotalEmployees FROM Employees GROUP BY Department HAVING TotalEmployees > 5 ORDER BY TotalEmployees;”?

A. SELECT Department
B. COUNT(*) AS TotalEmployees
C. HAVING clause misuse
D. ORDER BY TotalEmployees

Shw me The Right Answer

Answer . C 

Q.217 Correct the error in
“SELECT Name FROM Employees WHERE Department IN (SELECT Department FROM Departments WHERE Location = ‘New York’) ORDER BY Name GROUP BY Department;”

A. WHERE Department IN
B. ORDER BY Name
C. GROUP BY Department
D. No error

Shw me The Right Answer

Answer . C 

Q.218 In “SELECT Department, COUNT(EmployeeID) FROM Employees GROUP BY Department HAVING COUNT(EmployeeID) > ALL (SELECT COUNT(EmployeeID) FROM Employees GROUP BY Department);” what needs correction?

A. Change ‘COUNT(EmployeeID)’ to ‘SUM(EmployeeID)’
B. Replace ‘GROUP BY’ with ‘ORDER BY’
C. Alter ‘ALL’ to ‘ANY’
D. No error

Shw me The Right Answer

Answer . C 

Q.219 Identify the mistake in
“SELECT Department, MAX(Salary) FROM Employees WHERE MAX(Salary) > 50000 GROUP BY Department;”

A. SELECT Department
B. MAX(Salary)
C. WHERE MAX(Salary) > 50000
D. GROUP BY Department

Shw me The Right Answer

Answer . C 

Q.220 What is incorrect in “SELECT * FROM Employees ORDER BY 3;”?

A. Change ‘ORDER BY 3’ to ‘ORDER BY ID’
B. Replace ‘*’ with ‘EmployeeID, Name’
C. Add ‘WHERE’ clause before ‘ORDER BY’
D. No error

Shw me The Right Answer

Answer . C 

Q.221 In “SELECT Department, SUM(Salary) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;”, identify the error.

A. Replace ‘SUM(Salary)’ with ‘AVG(Salary)’
B. Change ‘GROUP BY’ to ‘ORDER BY’
C. Change ‘COUNT(*)’ to ‘COUNT(Department)’
D. No error

Shw me The Right Answer

Answer . B 

Q.222 Correct the syntax error in
“SELECT Name, Department, COUNT(*) FROM Employees WHERE Department = ‘Sales’ GROUP BY Department;”

A. SELECT Name
B. Department
C. COUNT(*)
D. WHERE Department = ‘Sales’

Shw me The Right Answer

Answer . B 

Q.223 What needs to be corrected in
“SELECT AVG(Salary) AS AverageSalary FROM Employees HAVING AverageSalary > 50000;”?

A. SELECT AVG(Salary)
B. AS AverageSalary
C. FROM Employees
D. HAVING AverageSalary > 50000

Shw me The Right Answer

Answer . D 

Q.224 Identify the error in
“SELECT Department, COUNT(*) FROM Employees GROUP BY Salary;”

A. SELECT Department
B. COUNT(*)
C. GROUP BY Salary
D. No error

Shw me The Right Answer

Answer . C 

Q.225 What is incorrect in “SELECT Name FROM Employees WHERE Department = ‘Sales’ ORDER BY Age;”?

A. Replace ‘ORDER BY Age’ with ‘GROUP BY Age’
B. Change ‘WHERE Department = ‘Sales” to ‘WHERE Department IN (‘Sales’)’
C. Remove ‘Name FROM’
D. No error

Shw me The Right Answer

Answer . A 

Q.226 In SQL, can the HAVING clause be used without an aggregate function?

A. Yes, it acts like a WHERE clause
B. No, it must be used with an aggregate function
C. Yes, but it has no effect
D. No, it causes an error

Shw me The Right Answer

Answer . A 

Q.227 What is the effect of combining GROUP BY with ORDER BY in an SQL query?

A. GROUP BY overrides ORDER BY
B. ORDER BY overrides GROUP BY
C. They can be used together for organized grouping and sorting
D. They cannot be used together in the same query

Shw me The Right Answer

Answer . C 

Q.228 Can the ORDER BY clause use column aliases defined in the SELECT statement?

A. Yes
B. No
C. Only if they are numerical
D. Only in subqueries

Shw me The Right Answer

Answer . A 

Q.229 What happens if you use a column in the SELECT statement that is not in the GROUP BY clause?

A. The query fails
B. The query succeeds, and the column shows arbitrary values
C. The query is automatically corrected
D. The column is ignored

Shw me The Right Answer

Answer . A 

Q.230 How does the ORDER BY clause treat NULL values by default?

A. It places them at the beginning of the result set
B. It places them at the end of the result set
C. It ignores them
D. It causes an error

Shw me The Right Answer

Answer . B 

Q.231 In an SQL query, what role does HAVING play without a GROUP BY clause?

A. It functions as a WHERE clause
B. It has no effect
C. It causes an error
D. It filters aggregated results

Shw me The Right Answer

Answer . A 

Q.232 What is the main difference between WHERE and HAVING clauses in SQL?

A. WHERE filters rows before grouping, HAVING filters rows after grouping
B. HAVING filters rows before grouping, WHERE filters rows after grouping
C. No difference
D. WHERE is used with aggregate functions, HAVING is not

Shw me The Right Answer

Answer . A 

Q.233 In SQL, how does the GROUP BY clause function when combined with an aggregate function like SUM or COUNT?

A. It calculates the aggregate for the entire table
B. It groups rows based on unique values in a column and calculates the aggregate for each group
C. It filters the rows before aggregation
D. It sorts the result set

Shw me The Right Answer

Answer . B 

Q.234 What is the purpose of the ORDER BY clause in SQL?

A. Filters rows
B. Sorts the result set
C. Groups rows
D. Joins tables

Shw me The Right Answer

Answer . B 

Q.235 What does the WHERE clause do in an SQL query?

A. Sorts the result set
B. Filters rows before grouping
C. Joins tables
D. Filters rows after grouping

Shw me The Right Answer

Answer . B 

Q.236 What needs to be changed in “UPDATE Employees SET Salary *= 2 WHERE YearsOfExperience > 5;”?

A. Change ‘*=’ to ‘=:=’
B. Remove ‘WHERE YearsOfExperience > 5’
C. Replace ‘2’ with ‘2.0’
D. No error

Shw me The Right Answer

Answer . B 

Q.237 Identify the mistake in
“SELECT * FROM Employees WHERE Department = ‘HR’ XOR Department = ‘Finance’;”

A. XOR operator
B. = ‘HR’
C. = ‘Finance’
D. No mistake, the statement is correct

Shw me The Right Answer

Answer . A 

Q.238 In “SELECT Name FROM Employees WHERE NOT (Age < 30 AND Department = ‘Sales’);”, identify the error.

A. Replace ‘NOT’ with ‘NO’
B. Change ‘AND’ to ‘OR’
C. Remove parentheses around condition
D. No error

Shw me The Right Answer

Answer . B 

Q.239 What is incorrect in “SELECT EmployeeID, Salary FROM Employees WHERE Salary BETWEEN 30000 AND 50000;”?

A. Change ‘BETWEEN’ to ‘IN’
B. Replace ‘AND’ with ‘OR’
C. Change ‘Salary’ to ‘TotalSalary’
D. No error

Shw me The Right Answer

Answer . C 

Q.240 Correct the syntax error in “UPDATE Products SET Price = Price * 1.1 WHERE Price < 100 OR Price > 200;”

A. Change ‘*’ to ‘+’ in ‘Price * 1.1’
B. Remove ‘OR Price > 200’
C. Replace ‘WHERE’ with ‘AND’
D. No error

Shw me The Right Answer

Answer . B 

Q.241 What needs to be corrected in “SELECT COALESCE(Salary, 0) FROM Employees;”?

A. Change ‘COALESCE’ to ‘NVL’
B. Replace ‘0’ with ‘10000’
C. Add ‘AS DefaultSalary’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.242 What does the COALESCE function do in SQL?

A. Returns the first non-null value in a list
B. Combines multiple rows into a single string
C. Duplicates a string
D. Compares two expressions and returns NULL if they are equal

Shw me The Right Answer

Answer . A 

Q.243 Correct the syntax error in “SELECT Name, TRY_CONVERT(INT, Age) AS IntegerAge FROM Employees WHERE Age IS NOT NULL;”

A. Change ‘TRY_CONVERT’ to ‘CONVERT’
B. Replace ‘INT’ with ‘INTEGER’
C. Remove ‘WHERE Age IS NOT NULL’
D. No error

Shw me The Right Answer

Answer . C 

Q.244 Identify the error in “SELECT CONVERT(VARCHAR, StartDate, 103) FROM Projects WHERE StartDate IS NOT NULL;”

A. Change ‘VARCHAR’ to ‘DATE’
B. Replace ‘103’ with ‘101’
C. Remove ‘WHERE StartDate IS NOT NULL’
D. No error

Shw me The Right Answer

Answer . C 

Q.245 What needs to be corrected in “SELECT CAST(Salary AS INT) FROM Employees;”?

A. Change ‘INT’ to ‘INTEGER’
B. Replace ‘CAST’ with ‘CONVERT’
C. Add ‘AS IntegerSalary’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.246 In “SELECT SQUARE(Length) FROM Rectangles;”, what needs correction?

A. Change ‘SQUARE’ to ‘SQRT’
B. Replace ‘Length’ with ‘Width’
C. Add ‘AS SquareLength’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.247 What is incorrect in “SELECT Name, PI() * Radius * Radius AS Area FROM Circles;”?

A. Replace ‘PI()’ with ‘3.14’
B. Change ‘Radius * Radius’ to ‘Power(Radius, 2)’
C. Remove ‘AS Area’
D. No error

Shw me The Right Answer

Answer . C 

Q.248 Correct the syntax error in “SELECT CEILING(Price) AS RoundedPrice FROM Products WHERE Price > 0;”

A. Change ‘CEILING’ to ‘FLOOR’
B. Replace ‘AS RoundedPrice’ with ‘AS PriceCeiling’
C. Remove ‘WHERE Price > 0’
D. No error

Shw me The Right Answer

Answer . C 

Q.249 Identify the error in “SELECT Name, SQRT(Age) FROM Employees WHERE Age >= 0;”

A. Change ‘SQRT’ to ‘SQUARE’
B. Replace ‘Age >= 0’ with ‘Age > 0’
C. Add ‘AS SquareRootAge’ for clarity
D. No error

Shw me The Right Answer

Answer . B 

Q.250 What needs to be corrected in “SELECT ROUND(Salary, 2) FROM Employees;”?

A. Change ‘ROUND’ to ‘ROUNDDOWN’
B. Replace ‘2’ with ‘-2’
C. Add ‘AS RoundedSalary’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.251 How does the SQUARE function differ from the POWER function in SQL?

A. SQUARE calculates the square, POWER calculates any exponent
B. SQUARE and POWER are the same
C. SQUARE calculates the square root, POWER calculates the square
D. SQUARE calculates any exponent, POWER calculates the square

Shw me The Right Answer

Answer . A 

Q.252 What is the purpose of the PI function in SQL?

A. To return the value of PI
B. To calculate the perimeter of a circle
C. To calculate the area of a circle
D. To return the radius of a circle

Shw me The Right Answer

Answer . A 

Q.253 In SQL, what is the result of the SQRT function when applied to a negative number?

A. A positive number
B. Zero
C. An error
D. A negative number

Shw me The Right Answer

Answer . C 

Q.254 What does the CEILING function do in SQL?

A. Returns the smallest integer greater than or equal to a given number
B. Returns the largest integer less than or equal to a given number
C. Calculates the square of a number
D. Calculates the square root of a number

Shw me The Right Answer

Answer . A 

Q.255 What is the purpose of the ROUND function in SQL?

A. To round a number to the nearest integer
B. To round a number to a specified number of decimal places
C. To find the square root of a number
D. To return the value of PI

Shw me The Right Answer

Answer . B 

Q.256 What is wrong in “SELECT * FROM Employees FULL OUTER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID WHERE Departments.DepartmentName IS NULL;”?

A. Replace ‘FULL OUTER JOIN’ with ‘LEFT JOIN’
B. Change ‘WHERE’ to ‘AND’
C. Remove ‘WHERE Departments.DepartmentName IS NULL’
D. No error

Shw me The Right Answer

Answer . C 

Q.257 In “SELECT * FROM Employees CROSS JOIN Departments;”, what needs correction?

A. Change ‘CROSS JOIN’ to ‘INNER JOIN’
B. Add ‘ON’ clause with condition
C. Remove ‘FROM Employees’
D. No error

Shw me The Right Answer

Answer . A 

Q.258 Identify the issue in
“SELECT E.Name, D.Name FROM Employees E JOIN Departments D ON E.DepartmentID > D.DepartmentID;”

A. JOIN keyword
B. > operator
C. No error
D. The ON clause

Shw me The Right Answer

Answer . B 

Q.259 Correct the syntax error in
“SELECT * FROM Employees A LEFT JOIN Departments B ON A.DepartmentID == B.DepartmentID;”

A. LEFT JOIN
B. ON clause
C. No syntax error
D. == operator

Shw me The Right Answer

Answer . D 

Q.260 What needs to be changed in
“SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID <> Customers.ID;”?

A. INNER JOIN
B. <> operator
C. No change
D. The ON clause

Shw me The Right Answer

Answer . B 

Q.261 In “SELECT * FROM Orders FULL JOIN Customers ON Orders.CustomerID = Customers.ID;”, identify the error.

A. Replace ‘FULL JOIN’ with ‘FULL OUTER JOIN’
B. Change ‘ON’ to ‘USING’
C. Add ‘WHERE Orders.OrderDate IS NOT NULL’
D. No error

Shw me The Right Answer

Answer . A 

Q.262 What is incorrect in
“SELECT A.Name, B.Name FROM Employees A, Employees B WHERE A.EmployeeID < B.EmployeeID;”?

A. The SELECT statement
B. The WHERE clause
C. No error, it is a SELF JOIN
D. The table aliases (A, B)

Shw me The Right Answer

Answer . C 

Q.263 Correct the syntax error in “SELECT * FROM Orders RIGHT OUTER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Orders.OrderDate = ‘2023-01-01’;”

A. Change ‘RIGHT OUTER JOIN’ to ‘LEFT OUTER JOIN’
B. Replace ‘WHERE’ with ‘AND’
C. Remove ‘Orders.’ prefix from ‘OrderDate’
D. No error

Shw me The Right Answer

Answer . A 

Q.264 Identify the error in “SELECT Employees.Name, Departments.Name FROM Employees LEFT JOIN Departments USING (DepartmentID);”

A. Change ‘LEFT JOIN’ to ‘RIGHT JOIN’
B. Replace ‘USING (DepartmentID)’ with ‘ON Employees.DepartmentID = Departments.DepartmentID’
C. Add ‘AS EmployeeName, AS DepartmentName’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.265 What needs to be corrected in “SELECT * FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;”?

A. Replace ‘INNER JOIN’ with ‘LEFT JOIN’
B. Change ‘ON’ to ‘USING’
C. Remove ‘Employees.’ prefix from ‘DepartmentID’
D. No error

Shw me The Right Answer

Answer . A 

Q.266 How does a NON-EQUI JOIN differ from an EQUI JOIN?

A. NON-EQUI JOIN uses non-equality operators, EQUI JOIN uses equality operators
B. NON-EQUI JOIN is faster than EQUI JOIN
C. NON-EQUI JOIN cannot be used with WHERE clause, EQUI JOIN can
D. There is no difference

Shw me The Right Answer

Answer . A 

Q.267 In a RIGHT JOIN, what happens to the rows from the right table that have no matches in the left table?

A. They are included in the result set with NULLs in the columns of the left table
B. They are excluded from the result set
C. They are included as duplicates
D. They are replaced with values from the left table

Shw me The Right Answer

Answer . A 

Q.268 What is an EQUI JOIN?

A. A join using an equality operator
B. A join using any comparison operator other than equality
C. A join based on the equidistant principle
D. A join that always produces an equal number of rows from both tables

Shw me The Right Answer

Answer . A 

Q.269 In SQL, what does a SELF JOIN refer to?

A. Joining a table with a different table
B. Joining a table with itself using a different alias
C. Joining a table with a copy of itself
D. Joining a table with its foreign key

Shw me The Right Answer

Answer . B 

Q.270 What is a LEFT JOIN in SQL?

A. A join that retrieves records from the left table only
B. A join that retrieves records from the right table only
C. A join that retrieves all records from the left table and matched records from the right table
D. A join that retrieves matched records from both tables

Shw me The Right Answer

Answer . C 

Q.271 What needs to be corrected in “CREATE OR REPLACE VIEW DepartmentSummary AS SELECT DepartmentID, COUNT(*) FROM Employees GROUP BY DepartmentID;”?

A. Change ‘CREATE OR REPLACE VIEW’ to ‘CREATE VIEW’
B. Replace ‘COUNT(*)’ with ‘COUNT(EmployeeID)’
C. Add ‘ORDER BY DepartmentID’ at the end
D. No error

Shw me The Right Answer

Answer . C 

Q.272 Identify the error in “CREATE VIEW ActiveEmployees AS SELECT * FROM Employees WHERE Status = ‘Active’;”

A. Change ‘CREATE VIEW’ to ‘CREATE TABLE’
B. Replace ‘*’ with specific column names
C. Remove ‘WHERE Status = ‘Active”
D. No error

Shw me The Right Answer

Answer . B 

Q.273 What is a materialized view in SQL?

A. A view that is automatically updated when the underlying tables change
B. A view that is created for temporary use only
C. A view that is stored physically on the disk
D. A view that can be indexed

Shw me The Right Answer

Answer . C 

Q.274 What is a view in SQL?

A. A physical table stored in the database
B. A temporary table created during a session
C. A virtual table based on the result-set of an SQL statement
D. A duplicate copy of another table

Shw me The Right Answer

Answer . C 

Q.275 Correct the syntax error in “SELECT Name, (SELECT MAX(Salary) FROM Employees) AS MaxSalary FROM Employees WHERE DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = ‘HR’);”

A. Change the inner ‘SELECT MAX(Salary)’ to ‘SUM(Salary)’
B. Remove ‘AS MaxSalary’
C. Replace the second ‘SELECT’ with ‘IN’
D. No error

Shw me The Right Answer

Answer . B 

Q.276 What needs to be corrected in “SELECT Name FROM Employees WHERE EXISTS (SELECT * FROM Departments WHERE Employees.DepartmentID = Departments.DepartmentID);”?

A. Change ‘WHERE EXISTS’ to ‘IF EXISTS’
B. Replace ‘*’ with ‘DepartmentID’
C. Add ‘GROUP BY Name’ at the end
D. No error

Shw me The Right Answer

Answer . B 

Q.277 Identify the error in “SELECT Name FROM Employees WHERE Salary > (SELECT AVG(Salary) FROM Employees);”

A. Replace ‘WHERE’ with ‘AND’
B. Change ‘>’ to ‘<‘
C. Add ‘GROUP BY’ after subquery
D. No error

Shw me The Right Answer

Answer . C 

Q.278 What is a correlated subquery in SQL?

A. A subquery that can be executed independently of the outer query
B. A subquery that uses values from the outer query
C. A subquery that returns multiple columns
D. A subquery used in the FROM clause

Shw me The Right Answer

Answer . B 

Q.279 In “SELECT Name, LTRIM(RTRIM(Name)) AS TrimmedName FROM Customers;”, what needs correction?

A. Change ‘LTRIM(RTRIM(Name))’ to ‘TRIM(Name)’
B. Remove ‘AS TrimmedName’
C. Replace ‘Name’ with ‘CustomerName’
D. No error

Shw me The Right Answer

Answer . B 

Q.280 What is incorrect in “SELECT UPPER(Name) FROM Employees;”?

A. Replace ‘UPPER’ with ‘LOWER’
B. Change ‘Name’ to ‘EmployeeName’
C. Add ‘AS UppercaseName’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.281 Correct the syntax error in “SELECT Name, CHARINDEX(‘a’, Name) FROM Employees WHERE Name IS NOT NULL;”

A. Change ‘CHARINDEX’ to ‘INDEXOF’
B. Replace ‘a’ with ‘%a%’
C. Remove ‘WHERE Name IS NOT NULL’
D. No error

Shw me The Right Answer

Answer . C 

Q.282 Identify the error in “SELECT SUBSTRING(Name, 1, 3) AS ShortName FROM Products;”

A. Change ‘SUBSTRING’ to ‘LEFT’
B. Replace ‘1, 3’ with ‘3’
C. Remove ‘AS ShortName’
D. No error

Shw me The Right Answer

Answer . C 

Q.283 What needs to be corrected in “SELECT CONCAT(FirstName, ‘ ‘, LastName) FROM Employees;”?

A. Change ‘CONCAT’ to ‘CONCATENATE’
B. Replace ‘,’ with ‘+’
C. Add ‘AS FullName’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.284 In “SELECT Name, LOG(Salary, 10) AS LogSalary FROM Employees WHERE Salary > 0;”, what needs correction?

A. Change ‘LOG’ to ‘EXP’
B. Replace ’10’ with ‘2’
C. Remove ‘WHERE Salary > 0’
D. No error

Shw me The Right Answer

Answer . C 

Q.285 What is incorrect in “SELECT MAX(Salary) – MIN(Salary) AS SalaryRange FROM Employees;”?

A. Replace ‘MAX’ with ‘SUM’
B. Change ‘-‘ to ‘+’
C. Remove ‘AS SalaryRange’
D. No error

Shw me The Right Answer

Answer . C 

Q.286 Correct the syntax error in “SELECT Name, ROUND(Salary, -2) FROM Employees;”

A. Change ‘ROUND’ to ‘TRUNC’
B. Replace ‘-2’ with ‘2’
C. Add ‘AS RoundedSalary’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.287 Identify the error in “SELECT Name, CEILING(Salary) FROM Employees WHERE Salary > 0;”

A. Change ‘CEILING’ to ‘FLOOR’
B. Replace ‘Salary > 0’ with ‘Salary >= 0’
C. Add ‘AS RoundedSalary’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.288 What needs to be corrected in “SELECT ABS(-123) FROM Dual;”?

A. Replace ‘ABS’ with ‘MOD’
B. Change ‘-123’ to ‘123’
C. Remove ‘FROM Dual’
D. No error

Shw me The Right Answer

Answer . C 

Q.289 In “SELECT Name, AGE(BirthDate) AS Age FROM Customers;”,
what needs correction?

A. AGE
B. BirthDate
C. AS Age
D. No error

Shw me The Right Answer

Answer . A 

Q.290 What is incorrect in “SELECT EXTRACT(MONTH FROM OrderDate) AS OrderMonth FROM Orders;”?

A. Replace ‘EXTRACT’ with ‘DATEPART’
B. Change ‘MONTH’ to ‘YEAR’
C. Remove ‘AS OrderMonth’
D. No error

Shw me The Right Answer

Answer . C 

Q.291 Correct the syntax error in “SELECT Name, DATEADD(MONTH, 6, HireDate) FROM Employees;”

A. Change ‘DATEADD’ to ‘DATEDIFF’
B. Replace ‘MONTH, 6’ with ‘YEAR, 1’
C. Remove ‘HireDate’
D. No error

Shw me The Right Answer

Answer . C 

Q.292 Identify the error in “SELECT Name, DATEDIFF(year, HireDate, GETDATE()) AS YearsWorked FROM Employees;”

A. Change ‘DATEDIFF(year, HireDate, GETDATE())’ to ‘DATEDIFF(day, HireDate, GETDATE())’
B. Replace ‘AS YearsWorked’ with ‘AS DaysWorked’
C. Remove ‘GETDATE()’
D. No error

Shw me The Right Answer

Answer . B 

Q.293 What needs to be corrected in “SELECT CURRENT_DATE FROM Employees;”?

A. Replace ‘CURRENT_DATE’ with ‘GETDATE()’
B. Remove ‘FROM Employees’
C. Add ‘AS Today’
D. No error

Shw me The Right Answer

Answer . B 

Q.294 Identify the error in “SELECT Name, CASE Gender WHEN ‘M’ THEN ‘Male’ WHEN ‘F’ THEN ‘Female’ END AS Gender FROM Employees;”

A. Change ‘CASE Gender’ to ‘CASE WHEN Gender’
B. Replace ‘END AS Gender’ with ‘END’
C. Add ‘ELSE ‘Other”
D. No error

Shw me The Right Answer

Answer . C 

Q.295 What needs to be corrected in “SELECT Name, CASE WHEN Age >= 18 THEN ‘Adult’ ELSE ‘Minor’ END FROM Employees;”?

A. Change ‘CASE WHEN’ to ‘IF’
B. Replace ‘>= 18’ with ‘> 18’
C. Remove ‘ELSE ‘Minor”
D. No error

Shw me The Right Answer

Answer . C 

Q.296 What is the main use of the CASE statement in SQL?

A. To execute a sequence of commands
B. To handle errors
C. To perform if-then-else type logic
D. To loop through records

Shw me The Right Answer

Answer . C 

Q.297 In “SELECT Name, NVL2(Salary, Salary * 1.1, Salary) AS NewSalary FROM Employees;”, what needs correction?

A. Change ‘NVL2’ to ‘COALESCE’
B. Replace ‘Salary * 1.1’ with ‘Salary + 1000’
C. Remove ‘AS NewSalary’
D. No error

Shw me The Right Answer

Answer . C 

Q.298 What is incorrect in “SELECT COALESCE(FirstName, LastName, ‘Unknown’) FROM Authors;”?

A. Replace ‘COALESCE’ with ‘NVL’
B. Change ‘Unknown’ to ‘NULL’
C. Add ‘AS FullName’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.299 Correct the syntax error in “SELECT NVL(Salary, ‘Not Provided’) FROM Contractors;”

A. Change ‘NVL’ to ‘COALESCE’
B. Replace ‘Not Provided’ with ‘0’
C. Add ‘AS SalaryStatus’ for clarity
D. No error

Shw me The Right Answer

Answer . C 

Q.300 Identify the error in “SELECT Name, NULLIF(Age, 30) FROM Employees WHERE Age IS NOT NULL;”

A. Change ‘NULLIF’ to ‘ISNULL’
B. Replace ‘Age, 30’ with ‘Age, 0’
C. Remove ‘WHERE Age IS NOT NULL’
D. No error

Shw me The Right Answer

Answer . C 

You may also like...

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments