ASSIGNMENT

UNIT - 2: Database Query using SQL

1) MySQL Functions and Querying using SQL

Multiple Choice Questions


1. Which type of SQL function work with a single-row at a time?
    (a) Multiple-row functions
    (b) Single-row functions
    (c) Both (a) and (b)
    (d) None of the above

2. Which function accepts a character string as an input and provides character string or numeric values as an output?
    (a) Text

    (b) Date
    (c) Time

    (d) Math

3. Which of the following is the correct syntax of LCASE( ) function?
    (a) LCASE(row_name)
    (b) LCE(column_name)
    (c) LCASE(str/column_name)
    (d) None of the above

 

4. Which of the following function converts the characters of an argument string to the uppercase characters?
    (a) UCASE( )
    (b) UPPER( )
    (c) Both (a) and (b)
    (d) None of the above

5. The correct output of
mysql>SELECT TRIM(LEADING '&' FROM '&&& India &&& ');
    (a) India &&

    (b) India &&&
    (c) && India

    (d) &&& India
 

6. The default date format is
    (a) MM-DD-YYYY

    (b) YYYY-MM-DD
    (c) DD-MM-YYYY

    (d) None of these
 

7. Which of the following function returns an integer that indicates the position of the first occurrence of the sub-string within the string?
    (a) INSTR( )

    (b) RTRIM( )
    (c) LENGTH( )

    (d) TRIM( )

8. Write the output of the following SQL command.
SELECT ROUND (47.89);
    (a) 47.88

    (b) 47.8
    (c) 48.0

    (d) 50

9. Which of the following function returns the name of the month from selected date?
    (a) MONTH(date)
    (b) MONTH_NAME(date)
    (c) MONTHNAME(date)
    (d) NAME_MONTH()

10. Which of the following function returns only the day number from month of selected date?

    (a) DAY(date)

    (b) DAYNO(date)

    (c) DAY_NUMBER(date)

    (d) DATE(date)

 

11. What will be returned by the given query?

SELECT ROUND(153.669,2);

    (a) 153.6

    (b) 153.66

    (c) 153.67

    (d) 153.7

12. What will be returned by the given query ?

SELECT INSTR('INDIA', 'DI');

    (a) 2

    (b) 3

    (c) −2

    (d) −3

 

Case-Based MCQs

 

13. Shanya Kumar is working with the following table Customers:

Table: Customers: