get query using joins

My Table

employee table
=emp id .. emp name
1    Ravi
2    Kumar
3    Gopal
4    Selvam
5    Raj
6    Sekar


dept table
-----
dept id .. emp id .. salary
1                  1    10000
1                  2    20000
2                   3    30000
2                     4    40000

Query

1. Using Join, select Employees not in the dept table

2. select max  of salary , dept id , emp_Name from dept  group by dept

Kindly provide me the query.

February 23rd, 2015 4:38am

Looks like homework/exercise given to you. Did you try to write queries by yourself? :)

You may ask your doubts/confusion.

-- 1) 
SELECT e.empid
	,e.empname
FROM employee e
LEFT JOIN dept d ON e.empid = d.empid
WHERE d.empid IS NULL
--2)
SELECT MAX(d.salary)
	,d.deptid
	,e.empName
FROM dept d
FULL JOIN employee e ON d.empid = e.empid
GROUP BY d.deptid, e.empname		
Free Windows Admin Tool Kit Click here and download it now
February 23rd, 2015 4:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics