UNIT 4-6 Flashcards
returns a four-digit year
YEAR(date_value)
returns a two-digit month code
MONTH(date_value)
returns the number of the day
DAY(date_value)
GETDATE()
SQL SERVER
DATE()
MS ACCESS
___ function produces a date by adding a specified number to a specified part of a date
DATEADD(DATEPART, NUM, DATE) SQL SERVER
DATE_ADD() MYSQL
function returns the difference between two parts of a date
DATEDIFF(datepart, stardate, enddate)
function subtracts a specified time interval from a date.
date_sub(date, interval expr type)
function returns the specified part of the date requested. SQL SERVER
datepart(datepart, date_field)
function is used to return a single part of a date/time, such as year, month, day, hour, minute, etc. MYSQL
EXTRACT(unit from date)
UNIT VALUES
MICROSECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR
Returns the current date and time
NOW()
Returns the current date
CURDATE()
Returns the current time
CURTIME()
Returns the current utc date
UTC_DATE()
Returns the current utc time
UTC_TIME()
function rounds numbers to a specified number of decimal places.
ROUND(numeric value, number of decimal places[optional])
operate on values in single rows, one row at a time. A ____“function” can be used to perform an arithmetic operation on a column
Row-level Functions
which returns the next larger integer value when a number contains decimal places.
CEILING()
which returns the next lower integer value when a number contains decimal places.
FLOOR()
which returns the square root of positive numeric values.
SQRT()
which returns the absolute value of any numeric value.
ABS()
which returns a number squared.
SQUARE()
function says that if the expression (or column value) is not null, return the value, but if the value is null, return ValueIfNull. SQL SERVER
ISNULL(expression1, ValueIfNull)
IFNULL()
which returns a NULL if expression1 = expression2. If the expressions are not equal, then expression1 is returned. BOTH LANGUAGES
NULLIF(expression1, expression2)
function is used to display or return from a result set the rows that fall at the top of a range specified by an ORDER BY clause.
TOP
option that can be used with the TOP function.
WITH TIES
returns a certain percentage of rows that fall at the top of a specified range.
PERCENT
so in order to get the bottom 10 percent, you would have to order the sname column in descending order and then select the top 10 percent
BOTTOM PERCENT
used in the SELECT statement to constrain the number of rows in a result set.
LIMIT
specifies the offset of the first row to return.
OFFSET
specifies maximum number of rows to return.
COUNT
The LIMIT clause often used with _____ clause
ORDER BY
a specialized conversion function that always converts from a number (for example, float or numeric) to a character data type
STR(float_expression, character_length, number_of_decimal_places)
function omits rows in the result set that contain duplicate data in the selected columns.
DISTINCT
___ the number X to a format like ‘#,###,###.##’, rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part. D should be a constant value. MYSQL
FORMAT(X,D)
function is also used to explicitly convert to a given data type. But, the ___ function has additional limited formatting capabilities.
CONVERT(desired_datatype[(length)], original_expression [, style])