Computer Knowledge
Database and SQL
4,213 Questions
Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.
SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions
Database and SQL Questions
B
Correct answer
Explanation
SQL allows ordering by column aliases defined in the SELECT list, because the alias is resolved after the SELECT clause but before ORDER BY is processed. Hence sorting by an alias is possible, making the claim that it isn’t possible false.
-
Single-row Functions and Double-row Functions
-
One-row Functions and Two-row Functions
-
Single-row Functions and Multiple-row Functions
-
None of the above
C
Correct answer
Explanation
SQL functions are categorized into single-row functions (operate on one row at a time, like UPPER, SUBSTR) and multiple-row functions (operate on groups of rows, like SUM, COUNT, AVG). This classification determines how they're used in queries.
B
Correct answer
Explanation
Single‑row functions, such as UPPER or SYSDATE, operate on each row individually and return exactly one value per row. They cannot produce multiple results from a single input row; that behavior belongs to set‑returning functions, making the statement false.
-
Table1.column1=Table2.column2
-
Table1.column1=Table2.column1
-
Table1.column2=Table2.column1
-
None of the above
B
Correct answer
Explanation
An equi-join is a join based on equality between columns, typically joining on the same column name from different tables. Option B shows Table1.column1 = Table2.column1, which represents an equi-join condition where the same column from both tables is being compared for equality.
-
CHECK keyword
-
WITH CHECK keyword
-
WITH CHECK OPTION keyword
-
None of the Above
C
Correct answer
Explanation
The WITH CHECK OPTION clause on a view ensures that any DML operation (INSERT/UPDATE) cannot create rows that the view’s defining query would exclude, protecting against modifications outside the sub‑query’s scope. The other keywords do not provide this restriction.
-
INSERT statement
-
UPDATE statement
-
Both of the Above
-
None of the Above
C
Correct answer
Explanation
Explicit DEFAULT values can be specified in both INSERT and UPDATE statements to force a column to use its defined default when the supplied value is omitted or set to DEFAULT. Therefore the option indicating both statements is correct; the others omit one context.
-
No. of rows in a table
-
No. of rows with non-null values of the expr
-
No. of distinct non-null values of the expr
-
None of the above
C
Correct answer
Explanation
COUNT(DISTINCT expr) counts unique non-null values. Unlike regular COUNT which counts total rows, DISTINCT removes duplicates before counting. NULL values are always excluded from the count.
-
Group By
-
NVL
-
Order By
-
Having
B
Correct answer
Explanation
NVL replaces null values with a specified substitute before aggregation, forcing group functions like SUM or AVG to treat nulls as a concrete value. GROUP BY controls grouping, ORDER BY sorts results, and HAVING filters groups, none of which alter null handling within aggregates.
-
HAVING
-
WHERE
-
Order By
-
Group by
A
Correct answer
Explanation
HAVING filters groups after aggregation, while WHERE filters individual rows before aggregation. You cannot use aggregate functions in WHERE, but you can in HAVING.
B
Correct answer
Explanation
Aggregate functions like COUNT, SUM, AVG cannot be used in WHERE clause because WHERE operates on individual rows before grouping. Use HAVING clause to filter on aggregate values.
-
All rows of the Employee table
-
Rows of the Employee table where the set grade is ‘Y’
-
Delete 1 row
-
Nothing will be deleted
B
Correct answer
Explanation
DELETE with WHERE clause removes only rows matching the condition. It will delete all Employee rows where grade equals 'Y'. If no rows match, nothing is deleted.