Page 175 - Informatics_Practices_Fliipbook_Class12
P. 175
3. MONTH()
The MONTH() function returns the month component of a given date or datetime value as an integer (1 to 12).
Example:
SELECT MONTH('2023-06-04');
Output: 6
In the above example, the MONTH() function returns the month component (June) of the date '2023-06-04'.
4. MONTHNAME()
The MONTHNAME() function returns the name of the month for a given date or datetime value.
Example:
SELECT MONTHNAME('2023-06-04');
Output: June
In the above example, the MONTHNAME() function returns the month name (June) for the date '2023-06-04'.
5. YEAR()
The YEAR() function returns the year component of a given date or datetime value.
Example:
SELECT YEAR('2023-06-04');
Output: 2023
In the above example, the YEAR() function returns the year component (2023) of the date '2023-06-04'.
6. DAY()
The DAY() function returns the day of the month for a given date or datetime value.
Example:
SELECT DAY('2023-06-04');
Output: 4
In the above example, the DAY() function returns the day of the month (4) for the date '2023-06-04'.
7. DAYNAME()
The DAYNAME() function returns the name of the weekday for a given date or datetime value.
Example:
SELECT DAYNAME('2023-06-04');
Output: Sunday
In the above example, the DAYNAME() function returns the weekday name (Sunday) for the date '2023-06-04'.
4.4.19 Aggregate Functions
SQL provides several functions where the selection criterion applies to an aggregate of tuples instead of a single tuple.
Some of the aggregate functions are described below:
Aggregate Functions: Applicable to an aggregate of tuples instead of a single tuple.
COUNT(): Returns the number of tuples satisfying a specified condition
1. COUNT(): The function COUNT() is used to display the count of the tuples satisfying a specified criterion. For
example, to find the number of employees earning 75000 or more, COUNT() function can be used as follows:
SELECT COUNT(*)
FROM EMPLOYEE
WHERE Salary >= 75000;
Database Query using SQL 161

