Category Archives: SQL Functions

SQL SUBSTRING Function – Get Part of String With Example

SUBSTRING function is used in sql to select part of text string in text. This function belongs to the group of text functions – string functions. I created a big summary of T-SQL text functions – you can find it here. Syntax SELECT SUBSTRING(text, <start position of the text character>, <the number of characters to… Read More »

SQL ISNULL and COALESCE Functions – What Are The Differences And Usage

ISNULL and COALESCE are functions used for work with null values (NULL). Both functions return first value out of previously defined entry parameters. There are also some differences between both functions. ISNULL Syntax: SELECT ISNULL(<Column>, <Column Replacement – other column or logic>) FROM dbo.Table  COALESCE Syntax: SELECT COALESCE(<Column>, <Column Replacement – other column or logic… Read More »

SQL String Functions – Overview of Text Functions in T-SQL

T-SQL is not a language designed primarily to do something big with text strings or manipulate with them. That is the reason why we will not find many text-related built-in functions. But we will definitely find use for those that are there. Let’s take a look at SQL String Functions. 1) Text Concatenation (Combining) –… Read More »

SQL Ranking Functions – ROW_NUMBER, RANK, DENSE_RANK, NTILE

SQL ranking functions enable us to rank records in the table based on values of a field or multiple fields. Clause OVER() is mandatory for the ranking functions. Ranking functions belongs to the group of Window functions. Aggregate functions and Offset functions (for paging) also belong to this group. List of Ranking Functions ROW_NUMBER ()… Read More »

SQL OFFSET Functions – LAG, LEAD, FIRST_VALUE, LAST_VALUE

OFFSET functions are relatively new to MS SQL Server. They are available since SQL Server 2012 version. These functions enable a user to “list” through rows of a table. To be precise, it makes you able to put hand on previous or next row while still at the current one. These functions belong to a… Read More »