February 1, 2008 at 9:16 am
DepartmentIDDepartmentName
1Human Resources
2Information Technology
3Marketing
4Legal
Table: Department
Table: Employee
EmployeeIDEmployeeNameDepartmentID
1 Paul3
2 John1
3 Mary4
4 JosephNull
5 Leo1
6 Mark3
7 Scott3
6.List all the departments that don’t have any employees. (Without using sub query)
7.List the departments with the number of employees.
9.How will you check the locks on a table?
Thanks,
Chinna
Its the Journey which gives you Happiness not the Destination-- Dan Millman
February 1, 2008 at 9:41 am
You should ask your teacher for help if you are having trouble with your homework.
February 1, 2008 at 1:36 pm
Posting your homework once is bad enough. Posting it twice is pushing the limits. Posting it three times...
http://www.sqlservercentral.com/Forums/Topic450568-338-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 4, 2008 at 1:04 am
pls find the queries below:-
List all the departments that don’t have any employees. (Without using sub query)
SELECT * FROM DEPARTMENT DEP
WHERE NOT EXISTS
(SELECT 'DEP' FROM EMPLOYEE EMP
WHERE EMP.DEP_ID=DEP.DEP_ID)
List the departments with the number of employees.
SELECT DEP_ID,COUNT(EMP_ID) FROM
EMPLOYEE
GROUP BY DEP_ID
February 4, 2008 at 2:44 am
Very cheeky answer - I think you're trying to get him into trouble. There is a subquery there!?
I think if you're going to post homework at least say that it's homework and be courteous in asking for help. Don't flower it and at least use some formatting....
Anyhow, you'll want to have a join between the tables and it's not an inner join. Look up table joins - there are several very easy to read articles on this site - and you'll see the answer with about 20 minutes work and then be able to code it yourself in your sleep.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply