Q1
True / FalseMySQL, the NOW() function returns the current date and time.
The NOW() function in MySQL returns the current date and time in the format YYYY-MM-DD HH:MM:SS
Q2
True / FalseThe CONCAT() function in MySQL can be used to combine two or more strings into one string.
The CONCAT() function in MySQL concatenates two or more strings together.
Q3
True / FalseThe COUNT() function in MySQL is used to calculate the total number of rows in a table.
The COUNT() function returns the number of rows that match a specified criterion or the total number of rows in a table if no criterion is specified.
Q4
True / FalseThe ROUND() function in MySQL can be used to round a number to a specified number of decimal places.
The ROUND() function rounds a number to the number of decimal places specified by its second argument
Q5
True / FalseThe SUBSTRING() function in MySQL extracts a specified number of characters from a string starting at a specified position.
The SUBSTRING() function extracts part of a string from a specified start position for a specified length.
Q6
True / FalseThe DATE_ADD() function in MySQL subtracts a time interval from a date.
The DATE_ADD() function adds a time interval to a date. To subtract a time interval, you should use the DATE_SUB() function.
Q7
True / FalseThe IFNULL() function in MySQL replaces NULL values with a specified replacement value.
The IFNULL() function returns the specified replacement value if the original value is NULL.
Q8
True / FalseThe CAST() function in MySQL converts a value from one data type to another.
The CAST() function allows for the conversion of a value from one data type to another, such as from a string to an integer.
Q9
True / FalseThe GROUP_CONCAT() function in MySQL concatenates values from multiple rows into a single string.
The GROUP_CONCAT() function concatenates values from multiple rows into a single string, separated by a specified delimiter.
Q10
True / FalseMySQL, the DATE_FORMAT() function allows you to format a date value according to a specified format string.
The DATE_FORMAT() function formats a date value according to the format string provided, allowing for various date and time representations.
Q21
Multiple ChoiceIdentify the correct SQL statement to create a user-defined function that returns the full name of a user.
SQL Code
CREATE FUNCTION get_full_name (first_name VARCHAR(100), last_name VARCHAR(100))
RETURNS VARCHAR(200)
BEGIN
RETURN CONCAT(first_name, ' ', last_name);
END;
This function concatenates the first name and last name with a space in between to return the full name.
Q26
Multiple ChoiceDetermine the correct SQL statement to create a function that calculates the discount for an order based on the order amount.
SQL Code
CREATE FUNCTION calculate_discount (order_amount DECIMAL(10,2))
RETURNS DECIMAL(10,2)
BEGIN
DECLARE discount DECIMAL(10,2);
IF order_amount > 100 THEN
SET discount = order_amount * 0.1;
ELSE
SET discount = 0;
END IF;
RETURN discount;
END;
This function calculates a 10% discount for orders over 100 and returns the discount amount.
Q30
Multiple ChoiceDetermine the correct SQL statement to create a function that converts a string to title case (capitalizing the first letter of each word).
SQL Code
CREATE FUNCTION to_title_case (input_string VARCHAR(255))
RETURNS VARCHAR(255)
BEGIN
DECLARE result VARCHAR(255);
SET result = CONCAT(UCASE(LEFT(input_string, 1)), LCASE(SUBSTRING(input_string, 2)));
RETURN result;
END;
This function capitalizes the first letter of the input string and converts the rest of the string to lowercase.