Category Archives: SQL Server

coalesce in MySql and MSSql

COALESCE function returns first not null value from list of all arguments. If all passed arguments are NULL, COALESCE returns NULL. COALESCE has N number of arguments. It works same for both MSSql and MySql. Syntax: COALESCE(arg1, arg2, arg3 [, argn]….); How it works? COALESCE is very easy to use. Let’s see how can you […]

Sql Server Partition By Clause

This is nothing new to many. The PARTITION BY Clause is used to do partition on query result as per given category. I love PARTITION BY Clause and after reading this you may love PARTITION BY Clause as well. Let’s take example how it works and when it needed. DECLARE @Employees TABLE( EmployeeID INT IDENTITY, […]

SQL Server Rank() v/s Dense_rank()

Yesterday night I was searching about SQL Server system functions and got a nice puzzle of SQL Server. The puzzle likes to find out second highest salary of each department and tie salary should also count. Finally decide to solve this puzzle and thinking It will be sort out by Rank() function. There is one another function to […]