Functions Flashcards
What performs a simple operation on exactly two inputs?
A binary operator
5.6
What is the syntax of a binary operator?
value1 operator value2
where value1 and value2 have similar data types.
(5.6)
What can arithmetic operators be use with?
Numeric values
5.6
What 5 arithmetic operators does the training companion list?
- Addition ( + )
- Subtraction ( - )
- Multiplication ( * )
- Division ( / )
- Modulus: the remainder when one number is divided by another ( % )
(5.6)
What arithmetic operator can be used to add whole or partial day (represented by a numeric value) to a date/time value?
The addition ( + ) operator
5.6
What arithmetic operator can be used to subtract whole or partial days (represented by a numeric value) to a date/time value?
The subtraction ( - ) operator
5.6
What is the concatenation operator and what does it do?
The concatenation operator ( + ) appends two string values together. If either value is null, the result is NULL.
(5.7)
Define a function.
A function takes a number of inputs, also called argument, and returns some sort of output, also called a result.
(5.8)
What does CURRENT_TIMESTAMP return?
The current date and time from the system. This is incredibly useful in comparing dates and lengths of time, such as in queries where you want to find all patient within a certain age range, or all new charges from last month.
(5.8)
What is the MONTH function argument?
A date.
Syntax: MONTH ( Date )
EX: Select MONTH (‘01-04-2009’)
(5.8)
What does the MONTH function return?
The month value from the date.
EX: Select MONTH (‘01-04-2009’)
=1
(5.8)
What is the DATEADD function argument?
- Interval (datepart)
- Number
- Date
EX: Select DATEADD (d, 15, ‘04 JAN 2009 23:42’) - - = 19 JAN 2009
What do functions require?
Arguments of the correct data type in the correct order.
For example, the DATEADD function requires one datepart, one number, and one date or datetime, in that order. Any invalid input will cause an error, and the query will not run.
(5.10)
Does using a function in the SELECT clause create a new column in your results?
Yes.
5.10
Do functions with no arguments require parentheses?
No.
EX: Select CURRENT_TIMESTAMP “Current Date”
(5.11)