Test Your SQL Basics - Part_2
Conversion Functions Questions
1. What will be the outcome of the following query?
SELECT ROUND(144.23,-1) FROM dual;
- 140
- 144
- 150
- 100
2. Which of the following commands is used to count the number of rows and non-NULL values in Oracle database?
- NOT NULL
- INSTR
- SUBSTR
- COUNT
3. Which of the following statements are true regarding the single row functions?
- They accept only a single argument.
- They can be nested only to two levels.
- Arguments can only be column values or constants.
- They can return a data type value different from the one that is referenced.
4. Which of the following type of single-row functions cannot be incorporated in Oracle DB?
- Character
- Numeric
- Conversion
- None of the above
5. Which of the following is true for the statement given as under.
NVL2 (arg1, arg2, arg3)
- Arg2 and Arg3 can have any data type
- Arg1 cannot have the LONG data type
- Oracle will convert the data type of expr2 according to Arg1
- If Arg2 is a NUMBER, then Oracle determines the numeric precedence, implicitly converts the other argument to that datatype, and returns that datatype.
6. What is true about the NULLIF function in Oracle DB?
- NULLIF(expr1,expr2) will return expr2 if the two expressions are NOT NULL.
- NULLIF(expr1,expr2) will return 0 if the two expressions are NULL.
- NULLIF(expr1,expr2) will return NULL if the two expressions are equal.
- Expr1 can be NULL in NULLIF(expr1, expr2)
7. Which of the following is not a property of functions?
- Perform calculations on data
- Convert column data types
- Modify individual data items
- None of the above
8. What is the most appropriate about single row functions?
- They return no value
- They return one result per row and operate on all the rows of a table.
- They return one result per row with input arguments
- They return one result per set of rows and operate on multiple rows.
9. What is the number of arguments Single Row functions accept?
- 0
- Only 1
- Only 2
- 1 or more than 1
10. Which of the following is an exception to the return value of a DATE type single-row function?
- TO_DATE
- SYSDATE
- MONTHS_BETWEEN
- TO_NUMBER
11. What is true about the CONCAT function in Oracle DB?
- It can have only characters as input.
- It can have only 2 input parameters.
- It can have 2 or more input parameters
- It joins values by putting a white space in between the concatenated strings by default.
12. What is true about the SUBSTR function in Oracle DB?
- It extracts a string of determined length
- It shows the length of a string as a numeric value
- It finds the numeric position of a named character
- It trims characters from one (or both) sides from a character string
Using the Group Functions Questions
1. Which of the following is NOT a GROUP BY function?
- MAX
- MIN
- NVL
- AVG
2. What are the appropriate data types accepted by GROUP BY functions?
- Nested Tables
- NUMBER
- CLOB
- DATE
3. A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.
SELECT COUNT (ALL num) FROM t_count;
- 12
- 6
- 9
- Throws exception because COUNT function doesn't works with NULL values
4. Which of the following is NOT a GROUP BY extensions in SQL?
- GROUP BY
- GROUPING SETS
- CUBE
- ROLLUP
5. Which of the following statements is true about the group functions?
- The MIN function can be used only with numeric data.
- The MAX function can be used only with date values.
- The AVG function can be used only with numeric data.
- The SUM function canÃt be part of a nested function.
6. Which of the following functions is used to calculate the total value stored in a specified column?
- COUNT
- ADD
- TOTAL
- SUM
7. Which of the following functions can be used to include NULL values in calculations?
- SUM
- NVL
- MAX
- MIN
8. Determine the correct order of execution of following clauses in a SELECT statement.
1.SELECT
2.FROM
3.WHERE
4.GROUP BY
5.HAVING
6.ORDER BY
- 2-3-4-5-1-6
- 1-2-3-4-5-6
- 6-5-4-3-2-1
- 5-4-2-3-1-6
9. What is true of using group functions on columns that contain NULL values?
- Group functions on columns ignore NULL values.
- Group functions on columns returning dates include NULL values.
- Group functions on columns returning numbers include NULL values.
- Group functions on columns cannot be accurately used on columns that contain NULL values.
10. Which of the following statements are true?
- AVG and SUM can be used only with numeric data types.
- STDDEV and VARIANCE can be used only with numeric data types.
- MAX can be used with LONG data type.
- MAX and MIN cannot be used with LOB or LONG data types.
11. Up to how many levels, the group functions can be nested?
- 1
- 2
- 3
- No limits
12. Which of the following are true about the CUBE extension of GROUP BY?
- Enables performing multiple GROUP BY clauses with a single query.
- Performs aggregations for all possible combinations of columns included.
- Performs increasing levels of cumulative subtotals, based on the provided column list.
- None of the above
Get Data from Multiple Tables Questions
1.Which of the following is not related to a Relational Database?
- Selection
- Projection
- Joining
- None of the above
2.Which of following will be used to join rows with other tables if the column values fall in a range defined by inequality operators?
- Equijoin
- Simple join
- Non-equijoin
- None of the above
3.What is true about a cartesian join of two tables in Oracle DB?
- It must be avoided as it is costly and non optimized
- It is formed when every row from one table is joined with all rows in the second table
- Both A and B
- None of the above
4.What is the main condition for using joins between a source table and a target table in Oracle DB for getting a non-cartesian product result?
- There is no condition
- At least one of the columns in both the tables should be common.
- The names of the columns in both the joining tables should be the same for using joins
- None of the above
5.What is true about Natural joins in Oracle DB?
- The column names of the source and the target tables should be identical
- If the column names of the source and the target tables are not same, Oracle implicitly does the needful
- NATURAL JOINS, USING and ON are the keywords associated with Natural Joins
- All of the above
6. The database designer has named the key (unique) columns from two tables differently.While joining these tables, which among the following will be the best practice?
- JOIN..ON
- Either NATURAL JOIN or JOIN...ON clauses
- Both A and B
- None of the above
7. What are Cartesian Joins also known as in Oracle DB?
- Equi-join
- Anti-join
- Cross-Join
- None of the above
8.Which of the following is used to avoid the ambiguous column problem in Oracle DB?
- ;
- ,
- .
- /
9.How many tables can be joined by using the JOINS in Oracle DB?
- 1
- 2
- 255
- No limit
10.What is true about Non-equijoins in Oracle DB?
- They join based on the keyword NON-EQUI JOIN
- They are used using the JOIN..ON clause with "=" sign
- The results are obtained when the result of the inequality mentioned evaluates to true.
- None of the above
11.On which of the following conditions is a row returned when an EQUI-JOIN is used to join tables?
- The result of the inequality match operation is true
- The result of the inequality match operation is 0
- The result of the inequality match operation is 1
- The result of the inequality match operation is false
12.In what scenarios can we use Self-Joins ideally in Oracle DB?
- When we need to find the duplicate records in a table
- When we need to obtain NULL values from a table
- When we need to display a column of a table twice
- When we need to display hierarchy of relevant entities
Subqueries to Solve Queries Questions
1. Which of the following are the types of sub-queries?
- Ordered sub-queries
- Grouped sub-queries
- Single row sub-queries
- None of the above
2.Which of the following clause is mandatorily used in a sub-query?
- SELECT
- WHERE
- ORDER BY
- GROUP BY
3.In which of the following clauses can a sub-query be used?
- HAVING
- WHERE
- FROM
- All of the above
4.Which of the following single-row operators can be used for writing a sub-query?
- >=
- <
- =
- All of the above
5.What among the following is true about sub-queries?
- Sub-queries can be written on either side of a comparison operator
- Parenthesis is not mandatory for sub-queries
- Single-row sub-queries can use multi-row operators but vice versa is not possible
- All of the above
6.What among the following is true about single-row sub-queries?
- They return only one row
- They use single-row operators
- Both A and B
- None of the above
7.Which of the following are valid multi row operators used for sub-queries?
- <=
- ANY >=
- !=
- >=
8.What does the ANY operator evaluates to in the above query?
- TRUE
- FALSE
- NULL
- 0
9.What can be said about the < ANY operator in the query given above?
- It gives the maximum value of salary
- It gives the minimum value of salary
- It means it gives the values that are lesser than the highest
- None of the above
10.What will be the outcome of the above query (the option A in the question above), if the < ALL is replaced with the >ALL?
- It will execute successfully giving the same result.
- It will throw an ORA error
- It will execute successfully but give the employees' details who have salaries lesser than all the employees with job_id 'FI_ACCOUNTANT'.
- None of the above
11.What is true about sub-queries in general?
- Sub-queries have to be executed separately from the main queries
- Sub-queries can be executed at the will of the user, they are not related to the main query execution
- Sub-queries are equal to two sequential queries where the results of inner query are used by the main query
- All of the above
12. What should be the best practice to follow when we know what values we need to pass on to the main query in Oracle queries?
- Using GROUP BY
- Using sub-queries
- Using HAVING
- None of the above
13.What is the maximum number of nesting level allowed in an Inline View type sub-query?
- 255
- 300
- 216
- Unlimited
Using the Set Operators Questions
1.Which SET operator does the following figure indicate?
- UNION
- UNION ALL
- INTERSECT
- MINUS
2.Which SET operator does the following figure indicate?
- UNION
- UNION ALL
- INTERSECT
- MINUS
3.What is true about the UNION ALL operator?
- It returns rows from the combined queries along with NULL values
- It returns rows for the combined queries after eliminating duplicates
- It returns rows for the combined queries along with duplicate values
- It returns rows for the combined queries ignoring the NULL values
4.What is the precedence of the set operators UNION, UNION ALL, INTERSECT and MINUS?
- UNION, UNION ALL, INTERSECT and MINUS
- MINUS, UNION, UNION ALL and INTERSECT
- INTERSECT, MINUS, UNION ALL, UNION
- Equal precedence
5.What is the order of evaluation of set operators?
- Left to Right
- Right to Left
- Random Evaluation
- Top to Bottom
6.What among the following is true about SET operators?
- SET operators cannot be used in sub-queries
- SET operators can only be used in the WHERE clause
- ORDER BY can be used for all queries combined by a SET operator
- SET operators can be used in sub-queries
7.What is the best way to change the precedence of SET operators given the fact that they have equal precedence?
- The order of usage of the SET operators can be changed to change the precedence
- The equal precedence cannot be changed
- Parenthesis can be used to change the precedence
- None of the above
8.What will happen if the SELECT list of the compound queries returns both a VARCHAR2 and a NUMBER data type result?
- Oracle will convert them implicitly and return a VARCHAR2 data type result
- Oracle will convert them implicitly and return a NUMBER data type result
- An ORA error is thrown
- None of the above
9.What is true about the UNION operator?
- It eliminates the duplicate values ignoring NULL values
- It returns duplicate values ignoring NULL values
- It returns duplicate values including NULL values
- It eliminates duplicate values and does not ignore NULL values
10.What is true about the INTERSECT operator?
- The number of columns and data types of the columns in the component queries should be the same
- The names of the columns and data types of the columns in the component queries should be the same
- Both A and B
- None of the above
11.What can be said about the result set if the order of the intersected tables is altered when using INTERSECT?
- The result is altered
- The result remains the same
- The sorting changes on alteration
- None of the above
Comments
Post a Comment