Computer Knowledge

Database and SQL

3,929 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

Multiple choice technology databases
  1. Return Top 3 Row in the Retailer Table

  2. Return Error

  3. Return No Record

  4. Return all Records from Retailer Table

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The subquery 'select top 3 Rtrid from retailer' returns multiple rows, but the WHERE clause uses '=' which expects a single value. Comparing a column to multiple rows with '=' causes an error - you should use 'IN' instead for multiple values.

Multiple choice technology databases
  1. Stored Procedure

  2. Function

  3. Table

  4. View

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Triggers are primarily associated with tables and execute in response to INSERT, UPDATE, or DELETE operations on that table. While INSTEAD OF triggers can also be created on views, tables are the fundamental object for which triggers are defined.

Multiple choice technology databases
  1. Min( )

  2. Sqrt( )

  3. Sum( )

  4. max( )

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Group functions (aggregate functions) like MIN(), MAX(), and SUM() operate on multiple rows and return a single result. SQRT() is a scalar function that operates on individual values, returning the square root of a single number, making it the correct answer as 'not a group function'.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName='%a%'

  2. SELECT * FROM Persons WHERE FirstName='a'

  3. SELECT * FROM Persons WHERE FirstName LIKE '%a'

  4. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The SQL LIKE operator with 'a%' matches any string starting with 'a'. The % wildcard matches zero or more characters. Option A ('%a%') would match any string containing 'a' anywhere. Option B is exact equality. Option C ('%a') matches strings ending with 'a'.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

  2. SELECT FirstName='Peter', LastName='Jackson' FROM Persons

  3. SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

  4. None

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The correct SQL uses WHERE with AND operator to combine two conditions. Option A uses <> which means 'not equal'. Option B has incorrect syntax - column names appear before FROM. The correct syntax is SELECT * FROM table WHERE column1='value1' AND column2='value2'.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen'

  2. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

  3. SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons

  4. None

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The BETWEEN operator in SQL is inclusive - it includes both endpoint values. Option A uses > and < which are exclusive and would exclude 'Hansen' and 'Pettersen'. Option C has incorrect syntax with column names before FROM. The BETWEEN operator is the cleanest solution for range queries.