Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Analysis Interviews:AnalysisAnalystAnalyst IntegrationAnalyst IntegrationAnecdotalBusiness AnalystCompetency BasedCredit AnalystCrime Scene AnalystData AnalystEmotional IntelligenceEvent PlannerExecutive Business AnalysisExecutive Business DevelopmentFemale SecretaryFinancial AnalystGISGIS AnalysisGIS DateMarket Research AnalystPension ExaminerPhone ScreeningPre EmploymentPre Employment ScreeningRecruitment/Research AnalystResearch AnalystResearch OfficerSales AnalystSpatial DataStatic AnalysisStatics MeasuresStatisticsSystem Analysis
Copyright © 2018. All Rights Reserved
Analyst Integration Interview Question:
Write an SQL query to find second highest salary in employee table?
Submitted by: AdministratorThis is one of the classic question from SQL interviews, event it's quite old it is still interesting and has lots of follow-up you can use to check depth of candidate's knowledge. You can find second highest salary by using correlated and non-correlated sub query. You can also use keyword's like TOP or LIMIT if you are using SQL Server or MySQL, given Interviewer allows you. The simplest way to find 2nd highest salary is following :
SELECT MAX(Salary) FROM Employee WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee)
This query first find maximum salary and then exclude that from list and again finds maximum salary. Obviously second time, it would be second highest salary.
Submitted by:
SELECT MAX(Salary) FROM Employee WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employee)
This query first find maximum salary and then exclude that from list and again finds maximum salary. Obviously second time, it would be second highest salary.
Submitted by:
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.