Tag: databases

Questions Related to databases

Which of the following statements gets the total value of the column 'Price' in the 'Sales' table

  1. SELECT ADD(Price) FROM Sales

  2. SELECT TOTAL(Price) FROM Sales

  3. SELECT SUM(Price) FROM Sales

  4. SELECT SUM(Price) WHERE Sales


Correct Option: C

AI Explanation

To answer this question, you need to understand how to calculate the total value of a column in a table using SQL.

Let's go through each option to understand why it is correct or incorrect:

Option A) SELECT ADD(Price) FROM Sales - This option is incorrect because there is no SQL function called ADD that can be used to calculate the total value of a column.

Option B) SELECT TOTAL(Price) FROM Sales - This option is incorrect because there is no SQL function called TOTAL that can be used to calculate the total value of a column.

Option C) SELECT SUM(Price) FROM Sales - This option is correct because the SUM function in SQL is used to calculate the sum of a column. By selecting SUM(Price) FROM Sales, you will get the total value of the 'Price' column in the 'Sales' table.

Option D) SELECT SUM(Price) WHERE Sales - This option is incorrect because the WHERE clause is missing a condition. The WHERE clause is used to filter rows based on a condition, but it needs to be followed by a condition. For example, WHERE Sales > 0. Without a condition, this query is invalid.

The correct answer is C) SELECT SUM(Price) FROM Sales. This option is correct because it uses the SUM function to calculate the total value of the 'Price' column in the 'Sales' table.

  1. The TRUNCATE clause deletes all rows in a database table, while the DELETE clause can have a WHERE condition and might or might not delete all rows in a table

  2. The TRUNCATE clause is identical to the DELETE clause

  3. The DELETE clause deletes all rows in a database table, while the TRUNCATE clause can have a WHERE condition and might or might not delete all rows in a table

  4. None of these


Correct Option: A
  1. ******3400

  2. 3400******

  3. 3400

  4. Error


Correct Option: D
  1. to_char(sysdate,'mm/yy')

  2. to_char('sysdate','mm/yy')

  3. to_char(sysdate,mm/yy)

  4. All the above


Correct Option: A

select nvl2(exp1,exp2,exp3) from dual. In this if exp1 is null,what will be the output?

  1. exp1

  2. exp2

  3. exp3

  4. error


Correct Option: B
  1. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

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

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

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


Correct Option: A