Essential MYSQL functions Flashcards
round 5.73
select round(5.73) ROUND(n,d, f) -- If f is not zero, then the ROUND() function rounds n to the d number of decimal places.
round 5.7345 within two digits from the decimal point
select round(5.7345, 2)
truncate 5.7345 two digits past the decimal
select truncate(5.7345, 2)
what is round is sql?
rounds a number to a specified number of decimal places
what is truncate in sql?
select truncate(5.7345, 2) TRUNCATE(n, d) -- function returns n truncated to d decimal places.
what is the ceiling of 5.2
select ceiling(5.3) #6 returns the smallest integer value that is larger than or equal to a number.
what is the floor of 5.2?
select floor(5.2) # 5 returns the largest integer value that is smaller than or equal to a number
what is the absolute value of -5.2 in sql?
select abs(-5.2) # 5.2 returns the absolute value of a number
write a random value between 0 and 1 in sql?
select rand()
find the length of string ‘karen’
select length(‘karen’) # 5
change string ‘karen’ to upper-case
select upper(‘karen’) # KAREN
change string ‘KAREN’ to lowercase
select lower(‘KAREN’) # karen
remove the space from the string ‘ kelvin’
select ltrim(‘ kelvin’) # kelvin
remove the space from the string ‘kelvin ‘
select rtrim(‘kelvin ‘) # kelvin
remove any leading or trailing spaces from a string
select trim(‘ kelvin ‘) # kelvin
return the first four characters of string Kindergarten
select left(‘Kindergarten’, 4)
select the last for characters in string Kindergarten
select right(‘Kindergarten’, 4)
obtain the substring wat from kelvinwaters
select substring(‘kelvinwaters’, 7, 3) # start at 7 then highlights 3 more values
what is the first position of ‘n’ in ‘kindergarten’?
select locate(‘n’, ‘kindergarten’) # 3