Skip to content

Instantly share code, notes, and snippets.

@dsaiztc
Last active August 29, 2015 14:24
Show Gist options
  • Save dsaiztc/da6ab6d28ccf7171652d to your computer and use it in GitHub Desktop.
Save dsaiztc/da6ab6d28ccf7171652d to your computer and use it in GitHub Desktop.
SQL functions.
# Aggregate functions
COUNT(column|*)
AVG(column)
MIN(column)
MAX(column)
SUM(column)
# Mathematical functions
ABS(number)
ROUND(number)
FLOOR(number)
CEILING(number)
SQRT(number)
POW(base, exponent)
RAND() # Random number n, 0<n<1
SIN(number) # Similar cos, etc.
# String functions
STRCMP(string1, string2) # Compare strings
LOWER(string)
UPPER(string)
LTRIM(string) # Left trim whitespace (similar right)
SUBSTRING(string, index1, index2)
PASSWORD(string) # Encrypt password
ENCODE(string, key)
DECODE(string, key)
CURDATE() # Get date
CURTIME() # Get time
DAYNAME(string) # Extract day name from date string
DAYOFWEEK(string) # Extract day number from date string
MONTHNAME(string) # Extract month from date string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment