Informatics Practices

Write the SQL functions which will perform the following operations:

(i) To return the summation of all non-NULL values of a data set.

(ii) To extract a substring starting from a position with a specific length.

(iii) To convert a string to uppercase.

(iv) To return the year for a specified date.

(v) To round off a number to a specified number of decimal places.

SQL Queries

3 Likes

Answer

(i)

SELECT SUM(column_name) 
FROM table_name;

(ii)

SELECT SUBSTRING(column_name, start_position, length) 
FROM table_name;

(iii)

SELECT UPPER(column_name) 
FROM table_name;

(iv)

SELECT YEAR(date_column) 
FROM table_name;

(v)

SELECT ROUND(column_name, decimal_places) 
FROM table_name;

Answered By

3 Likes


Related Questions