Thursday, March 16, 2017

How to find Nth highest and lowest salary in SQL?

This is the one of the most common question asked in SQL.

 "How to find Nth highest or lowest salary in SQL"

If you find the answer using the "TOP" keyword 
Than  interviewer ask you can you find out with other way 

so i will tell to some step including the top

But before start we need one employee table it is as below 







1. To get max salary from Employee table.


SELECT MAX(salary) FROM employee;

2. To get salary using Top.

SELECT TOP 1 Salary AS 'Higest Salary',Name FROM (SELECT DISTINCT TOP 3 Salary,Name FROM tblSalary ORDER BY Salary DESC) a ORDER BY Salary ASC 


Instatllation process of MSMQ properly in the computer(OS Window Server 2012 r2) using GUI

Microsoft Messaging Queue (MSMQ) technology is used for asynchronous communication using messages. MSMQ also can be considered to be an Inter- process communication capability.

Step 1: Need to ensure MSMQ is properly installed in the computer.


1. How to check?
  • Type "compmgmt.msc" in the Run window or right-click on MyComputer and select "Manage Computer".
  • The following screen shot shows the MSMQ installed in the computer, if its not listed then follow Step "c" else done.



Go to the Control Panel and select "Add or remove programs" under "Programs and Features"
  • After clicking on "Add or remove programs" again click "Turn Windows features on or off" displayed on left side select "Local Sever" from Server Manager.
  • When you click on "Local Sever" new window will be open "Add Roles and Features Wizard" Click Next.when you Got "Features" Option on left side.
  • Check (as in the following screenshot) whether MSMQ is enabled or not; if not then select "Enable" and press "OK"; see:




2. Once MSMQ is installed expand the MSMQ feature; there will be the following queues:
  • Private queues are queues that are not published in the Active Directory Domain Services and are displayed only on the local computer that contains them.
     
  • Public queues: In a domain environment, public queues are queues that are published in Active Directory Domain Services and hence are replicated throughout your Windows Server .