May 2019

Nth Highest Salary


Create table #tblEmployee (Id int, [Name] varchar(100), City varchar(100), Salary decimal (10,3))
Insert into #tblEmployee values(1, 'Prakash Rathod', 'Gandhinagar', 100000)
Insert into #tblEmployee values(2, 'Salman Khan', 'Mumbai', 100000)
Insert into #tblEmployee values(3, 'Aamir Khan', 'Mumbai', 90000)
Insert into #tblEmployee values(4, 'Katrina Kaif', 'Mumbai', 80000)
Insert into #tblEmployee values(5, 'Rashmi Bansal', 'Indor', 95500)
Insert into #tblEmployee values(6, 'Jinen Kothari', 'Ahmedabad', 60000)
Insert into #tblEmployee values(7, 'Deepika Patel', 'Gandhinagar', 60000)
Insert into #tblEmployee values(8, 'Ranbir Singh', 'Gandhinagar', 36000)
Insert into #tblEmployee values(9, 'Mohini Trivedi', 'Ahmedabad', 25000)
Insert into #tblEmployee values(10, 'Jalpa Patel', 'Surat', 100000)
Insert into #tblEmployee values(11, 'Kruti Patel', 'Surat', 100000)
Insert into #tblEmployee values(12, 'Viral Zala', 'Surat', 100000)
Insert into #tblEmployee values(13, 'Dipbha Parmar', 'Surat', 100000)
Insert into #tblEmployee values(14, 'Jagubha Chotu', 'Gandhinagar', 100000)
Insert into #tblEmployee values(15, 'Kailashba Rathod', 'Surat', 100000)
select * from #tblEmployee

--2nd hightest salary
--SELECT top 1 Salary FROM #tblEmployee
--WHERE Salary < (select max(salary) from #tblEmployee ) ;With Result As ( select salary, DENSE_RANK() over (order by salary desc) as RowNumber from #tblEmployee ) select salary from result where RowNumber=1 drop table #tblEmployee

Generate x509 certificate in pem, cer and pfx and export public key

Generate x509 cerntifcate

c:\Demo>openssl req -x509 -days 365 -newkey rsa:2048 -keyout my-key.pem -out -my-cert.pem

Generating a RSA private key
………………………+++++
…………..+++++
writing new private key to ‘my-key.pem’
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:IN
State or Province Name (full name) [Some-State]:Gujarat
Locality Name (eg, city) []:Gandhinagar
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company Name
Organizational Unit Name (eg, section) []:Development
Common Name (e.g. server FQDN or YOUR name) []:www.yourcompany.com
Email Address []:your@emailaddress.com

Generate .PFX file

c:\Demo>openssl pkcs12 -export -in -my-cert.pem -inkey my-key.pem -out my-xero.pfx
Enter pass phrase for my-key.pem:
Enter Export Password:
Verifying - Enter Export Password:

Generate .cer certificate

c:\Demo>openssl pkcs12 -export -in -my-cert.pem -inkey my-key.pem -out my-xero.cer
Enter pass phrase for my-key.pem:
Enter Export Password:
Verifying - Enter Export Password:

Export public key


c:\Demo>openssl pkcs12 -in my-xero.pfx -clcerts -nokeys -out myxeropublic.cer
Enter Import Password:

Reference: https://www.youtube.com/watch?v=3EBXAtyB6ys