SQLTeam.com | Weblogs | Forums

Sql Query for

In this MySQL challenge, your query should return the information for the employee with the third highest salary. Write a query that will find this employee and return that row, but then replace the DivisionID column with the corresponding DivisionName from the table cb_companydivisions. You should also replace the ManagerID column with the ManagerName if the ID exists in the table and is not NULL.

SELECT DISTINCT salary

FROM maintable_1YA0N E WHERE

3 =(SELECT COUNT(DISTINCT salary)

FROM maintable_1YA0N WHERE E.salary <= salary)

hi

please see below link !!! hope it helps :slight_smile:

Hi,

Thanks for the answer ... I have the 3rd Highest Salary but how to solve

eplace the DivisionID column with the corresponding DivisionName from the table cb_companydivisions. You should also replace the ManagerID column with the ManagerName if the ID exists in the table and is not NULL.

Blockquote

SELECT DISTINCT salary

FROM maintable_1YA0N E WHERE

3 =(SELECT COUNT(DISTINCT salary)

FROM maintable_1YA0N WHERE E.salary <= salary)

the table or tables
where these columns are DivisionName ManagerName
join on ID Columns and get these

Manager Name is self Join

and Division Name is imaginary Table - Will have the DivisionName column corresponding Division ID column

table

if manager name is in same table !!
you can just select manager name

imaginary table join on Division Id .. and select Division Name

division

Division Table

Please provide sample data as proper ddl and dml and not as pictures help us help you

join on ID .. take DivisionName