[go: up one dir, main page]

0% found this document useful (0 votes)
292 views2 pages

Home Work Function in MySQL 11 Apr 2020 (ANSWERS)

This document discusses MySQL functions including: - Single row functions operate on a single value to return a single value while aggregate functions operate on multiple rows. - Examples of categories of single row functions are math, text, and date functions. - Functions like MONTH() return a number, LENGTH() returns a number from a string, and DATE() returns a date. - SQL statements are provided to use functions like SUBSTR(), LENGTH(), INSTR(), and MONTHNAME().

Uploaded by

vikas_2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
292 views2 pages

Home Work Function in MySQL 11 Apr 2020 (ANSWERS)

This document discusses MySQL functions including: - Single row functions operate on a single value to return a single value while aggregate functions operate on multiple rows. - Examples of categories of single row functions are math, text, and date functions. - Functions like MONTH() return a number, LENGTH() returns a number from a string, and DATE() returns a date. - SQL statements are provided to use functions like SUBSTR(), LENGTH(), INSTR(), and MONTHNAME().

Uploaded by

vikas_2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Answers of

Function in MySQL (Home work)


11 Apr 2020
Multiple Choice Questions

1) Single row functions operate on a single value to return a single value.


2) SUM, AVG, COUNT are examples of multiple row or aggregate functions.
3) SELECT POW(-3,2) will display the output: 9
4) INSTR(str,str2) returns the position of the first occurrence of str2 in str1.
5) Any String function returns string or numeric type data.

Answer the following questions.

1) Define a Function.
Ans. Functions are used to manipulate data.

2) List 3 categories of single row functions. Give two examples in each


category.
Ans. Three categories of single row functions are:
1. Math / Numeric functions
e.g power(), round()
2. Text / String functions
e.g. length(), substring()
3. Date and Time functions
e.g. month(), dayname()

3) Name a
i) date function that returns a number. month(), year()
ii) String function that returns a number. length(), instr()
iii) date function that returns a date. date()
4) Write SQL statements to do the following:
i) Use the string "Internet is a boon" and extract the string "net".
Ans. Select substr("Internet is a boon", 6, 3);
ii) Display the length of the string "Informatics Practices".
Ans Select length("Informatics Practices");
iii) Display the position of "My" in "Enjoying MySQL".
Ans Select Instr("Enjoying MySQL", "My");
iv) Display the name of current month.
Ans Select monthname(now());

5) Write the output that the following statements will produce:


i) SELECT ROUND(7.3456, 2); 7.35
ii) SELECT ROUND(356.3456, -2); 400
iii) SELECT MONTHNAME('2009-08-25'); August
iv) SELECT MONTH('2010-02-26'); 2
v) SELECT RIGHT('Informatics', 4); tics

You might also like