1.

Classify various built-in functions in SQL.

Answer»

The built-in functions are classified as Single row functions and Group functions. The single-row functions are of four types. They are numeric functions, character or text functions, date functions, and conversion functions.

1. Numeric functions:
a. ABS function- The ABS function returns the absolute value of the number you point to.

b. CEIL and FLOOR functions - CEIL returns the smallest integer greater than or equal to its argument. FLOOR does just the reverse, returning the largest integer equal to or less than its argument.

c. POWER function – To raise one number to the power of another, use POWER. In this function the first argument is raised to the power of the second.

d. SORT function – The function SORT returns the square root of an argument.

2. Character or text functions:
1. CHR function – returns the character equivalent of the number it uses as an argument.
2. CONCAT function – function combines two strings together.

3. INITCAP function – capitalizes the first letter of a word and makes all other characters lowercase.
4. LOWER and UPPER functions – LOWER changes all the characters to lowercase; UPPER does just the reverse.
5. LENGTH function - returns the length of its lone character argument.

3. Date functions:
1. ADD_MONTHS function - This function adds a number of months to a specified date.
2. LAST_DAY – LAST_DAY function- returns the last day of a specified month.

3. MONTHS_BETWEEN function – to know how many months fall between month x and
month y,
4. NEXT_DAY function – finds the name of the first day of the week that is equal to or later than another specified date.
5. SYSDATE function – SYSDATE returns the system time and date.

4. Conversion functions:

  • TO_CHAR function – to convert a number into a character.
  • TO_NUMBER function – it converts a string into a number.

The group functions are:

  1. AVG() - Returns the average value
  2. COUNT() - Returns the number of rows
  3. FIRST() - Returns the first value
  4. LAST() - Returns the last value
  5. MAX() - Returns the largest value
  6. MIN() - Returns the smallest value
  7. SUM() - Returns the total value of the given column


Discussion

No Comment Found

Related InterviewSolutions