Translate

Sunday, 6 March 2016

SQL Query to second find highest salary of Employee

n= 0 for first record salary
n = 1 second highest salary 
n= 2 third highest salary 

SELECT DISTINCT(Salary) FROM Employees ORDER BY Salary DESC LIMIT n,1


Also some other queries 

select MAX(Salary) from Employee WHERE Salary NOT IN (select MAX(Salary) from Employee ); 


SELECT salary  FROM (SELECT DISTINCT(salary) FROM Employees ORDER BY salary DESC LIMIT 2) AS emp ORDER BY salary LIMIT 1;

Thursday, 3 March 2016

Difference between git merge and git rebase

I would suggest take an overview of this link, this would help you to understand actually how git rebase and merge works.

What is SQL Injection

-> manipulating web application parameters. 
-> bypass authorization. 
->  carry out data manipulation or reading arbitrary data

Wednesday, 2 March 2016

Difference between Include and Joins

:join :- It joins table together in sql. eg; Category.joins(:articles) SELECT categories.* FROM categories INNER JOIN articles ON articles.category_id = categories.id :includes :- Active Record ensures that all of the specified associations are loaded using the minimum possible number of queries. - It is a solution of n+1 query eg:- Article.includes(:comments).where(comments: { visible: true }) SELECT "articles"."id" AS t0_r0, ... "comments"."updated_at" AS t1_r5 FROM "articles" LEFT OUTER JOIN "comments" ON "comments"."article_id" = "articles"."id" WHERE (comments.visible = 1) I