interview

How to insert value in Identity column ? TIP #80

  Happy new year 2015 . Suppose you have a source table and one destination table (Which is exact replica of source table) and you want to copy all the rows of source table into destination table. Now the challenging part here is that there is an identity column and in source & destination table …

Grouping Sets–Good to know feature TIP# 60

  Grouping sets is one of the cool feature came in SQL SERVER 2008. Lets understand here with problem and solution. Problem:-  Suppose , We want  an aggregation result in a query with different groups. Firstly we want aggregated result on first column then combination of First & second column then other column combination. So, …

Interview Question- How conditionally sort the records ? TIP#43

  Problem:- Can we sort records according to particular condition ? Solution:- Most of the time developer faces this challenge of sorting records conditionally. I know  many of us faces this question in interview. Lets understand this by an example. Suppose I have a person table in database and  I want to sort the records …

Different way to find 2nd minimum Salary TIP #36

  Mostly people faced this question in interview find highest salary so I am just trying to explain different ways let us understand this by following example suppose we have following table of employees with salary Query 1:-  by  aggregate function SELECT MAX (fltBasicSalary)FROM @tblEmployeeSalaryWHERE fltBasicSalary IN (SELECT DISTINCT TOP 2 fltBasicSalaryFROM @tblEmployeeSalaryORDER BY fltBasicSalary …