SQL Interactive Learning Tool


Data Table - company.employees

Employee Table
id first_name job_title department_id salary vacation_days birthday
101 Frank Manager 2 3 123000 5 3/15/1994 00:00:00
213 Jane Developer 2 135000 2 6/14/1980 00:00:00
279 Ashley Manager 2 3 140000 3 12/5/1975 00:00:00
401 Glenn NULL NULL 115000 -3 3/23/1988 00:00:00
405 Kelly Developer 2 125000 2 10/11/1979 00:00:00
417 Richard Business Operations 1 120000 -7 8/30/1985 00:00:00
563 George Sales Representative 1 105000 2 2/18/1992 00:00:00
680 Kyle Security 5 200000 1 4/7/1983 00:00:00
881 James Developer 2 107000 -2 9/27/1978 00:00:00
908 Gustavo Accountant 1 100000 -10 11/21/1987 00:00:00

Query Input

SQL Learning Widget

Aggregate Functions:

Calculate the average value of a specified numeric column.
Learn more
Count the number of rows that are being returned.
Learn more
Return the highest value in a specified column.
Learn more
Return the lowest value in a specified column.
Learn more
Calculate the standard deviation of values in a specified numeric column.
Learn more
Calculate the total sum of a numeric column.
Learn more
Calculate the variance of values in a specified numeric column.
Learn more

String Functions:

Return the ASCII code of the first character in a string.
Learn more
Return the character based on the ASCII code provided as an argument.
Learn more
Return the number of characters in a string (length of the string).
Learn more
Return the starting position of a substring within a string.
Learn more
Concatenate two or more strings together.
Learn more
Compute the difference value between two strings based on their SOUNDEX values.
Learn more
Convert a string to lowercase.
Learn more
Extract a specified number of characters from the left side of a string.
Learn more
Return the number of characters in a string (length of the string).
Learn more
Find the starting position of a substring within a string.
Learn more
Convert a string to lowercase.
Learn more
Return the position of the first occurrence of a substring within a string.
Learn more
Replace all occurrences of a substring within a string with another substring.
Learn more
Extract a specified number of characters from the right side of a string.
Learn more
Return a string of spaces of a specified length.
Learn more
Remove leading and trailing spaces from a string.
Learn more
Convert a string to uppercase.
Learn more
Convert a string to uppercase.
Learn more

Numeric Functions:

Return the absolute value of a numeric expression.
Learn more
Return the smallest integer greater than or equal to a given number.
Learn more
Calculate the exponential value of a number.
Learn more
Return the largest integer less than or equal to a given number.
Learn more
Calculate the natural logarithm (base e) of a number.
Learn more
Calculate the logarithm of a number with a specified base.
Learn more
Calculate the base-10 logarithm of a number.
Learn more
Calculate the remainder of a division operation.
Learn more
Return the mathematical constant Pi.
Learn more
Raise a number to the power of another number.
Learn more
Convert an angle from degrees to radians.
Learn more
Generate a random number between 0 and 1.
Learn more
Round a number to a specified number of decimal places.
Learn more
Return the sign of a numeric expression (-1 for negative, 0 for zero, 1 for positive).
Learn more
Calculate the square root of a number.
Learn more

Date and Time Functions:

Add a specified number of days to a date.
Learn more
Add a specified time interval to a given time value.
Learn more
Return the current date.
Learn more
Return the current time.
Learn more
Add a specified time interval to a date or datetime value.
Learn more
Format a date or datetime value based on a specified format string.
Learn more
Subtract a specified time interval from a date or datetime value.
Learn more
Calculate the difference between two dates in terms of a specified unit (e.g., days, months, years).
Learn more
Extract the day of the month from a date or datetime value.
Learn more
Return the name of the day of the week for a given date.
Learn more
Return the day of the month (1-31) for a given date.
Learn more
Return the day of the week as a number (1 for Sunday, 2 for Monday, ..., 7 for Saturday) for a given date.
Learn more
Return the day of the year (1-366) for a given date.
Learn more
Return the hour component (0-23) of a time or datetime value.
Learn more
Return the minute component (0-59) of a time or datetime value.
Learn more
Return the month component (1-12) of a date or datetime value.
Learn more
Return the second component (0-59) of a time or datetime value.
Learn more
Return the year component of a date or datetime value.
Learn more

Ranking Functions:

Note: When using functions in this section, the original data will be sorted, so if you run any other functions after, the order wont match the dataset above anymore, refresh the page if you wish to test out other functions while matching the data order above.
Assign a rank to each row within a result set, where rows with equal values get the same rank, and no gaps in the ranking sequence are allowed.
Learn more
Return the value of the specified expression from the first row of the window frame defined by the window function.
Learn more
Retrieve the value from a previous row within the result set, based on a specified column or expression.
Learn more
Return the value of the specified expression from the last row of the window frame defined by the window function.
Learn more
Retrieve the value from a subsequent row within the result set, based on a specified column or expression.
Learn more
Divide the result set into a specified number of approximately equal groups (tiles), assigning a bucket number to each row.
Learn more
Calculate the relative rank of each row within a result set, expressed as a percentage.
Learn more
Assign a unique rank to each row within a result set based on a specified column or expression.
Learn more
Assign a unique sequential row number to each row within a result set.
Learn more

Conditional Functions:

Perform conditional logic in SQL, similar to if-then-else statements in programming languages.
Learn more
Return the first non-null expression in a list of expressions.
Learn more
Conditional transformation of values, primarily used in Oracle SQL.
Learn more
Conditionally return a value based on a boolean expression.
Learn more
Return the second value if the first value is null.
Learn more
Return one of two values depending on a boolean expression (SQL Server).
Learn more
Return the replacement value if the expression is null (SQL Server).
Learn more
Return null if two expressions are equal, otherwise return the first expression.
Learn more

Conversion Functions:

Convert an expression from one data type to another in SQL.
Learn more
Convert an expression from one data type to another in SQL (supports additional formatting).
Learn more
Convert a string representation of a date/time value to a datetime data type in SQL Server.
Learn more
Safely attempt to convert an expression from one data type to another; returns null if conversion fails.
Learn more
Safely attempt to convert an expression from one data type to another with additional formatting options; returns null if conversion fails.
Learn more
Safely attempt to convert a string representation of a date/time value to a datetime data type in SQL Server; returns null if conversion fails.
Learn more