473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Query to Get A Parent Record When All Child Records Have The Same Condition

68
Good day all,

I find myself stumped unable to build a query. I have a parent table for Departments, and a child table for Employees which is related to the Departments table by Department ID. In each departments there are number of employees with different job title. However, in some departments, all the employees have the same job title.

I need to write a query to get the departments that have employees whose jobs is the same. Let's say that I have the below departments and its relevant employees. How can I write a query to bring up the Department that all of its employees have "Driller" job title which is Department ID#2?

Departments Table (Parent)
1- Dept ID#1 Dept Name= Oil
2- Dept ID#2 Dept Name=Gas
3- Dept ID#3 Dept Name=Drilling

Employees Table (Child)
Dept ID#1 EmployeeID# 12345 Job Title=Driller
Dept ID#1 EmployeeID# 67899 Job Title=Forman
Dept ID#1 EmployeeID# 33445 Job Title=Operator

Dept ID#2 EmployeeID# 44556 Job Title=Driller
Dept ID#2 EmployeeID# 22345 Job Title=Driller
Dept ID#2 EmployeeID# 90901 Job Title=Driller

Dept ID#3 EmployeeID# 50601 Job Title=Driller
Dept ID#3 EmployeeID# 90902 Job Title=Driller
Dept ID#3 EmployeeID# 30030 Job Title=Forman
Jun 26 '12 #1
2 1863
Rabbit
12,516 Expert Mod 8TB
Make an aggregate query that counts all employees by department and join that to an aggregate query that counts all employees by department and title. Those with the same numbers are the departments you're looking for.
Jun 26 '12 #2
ahd2008
68
A Very smart suggestion from smart guy. Thanks so much Rabbit; that's absolutely the best approach.

Regards,
Jun 27 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: news.online.no | last post by:
In a query, I need too be able to show if a parent record has a child record. Using the query in a combo box too select record in a form. Thanks :)
5
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
1
by: accessbee | last post by:
(Sorry this is so long, was trying to fully explain the situation) There are two tables that handle information on our clients. Every client has a unique ClientID, and the ClientID is the Primary Key...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
1
by: vidhyapriya | last post by:
when i minimize child window the parent window should be minimize...how it possible..i need code in vb.net anyone tell me
2
by: vidhyapriya | last post by:
is it possible to deactivate parent window form when child window form active if so,can u give some idea or coding about this....i m using vb.net window appln
1
by: scottbouley | last post by:
I'm building a view in SQL Server 2000 Enterprize Manager to find any parent supply request records that are "Open" where all of the child detail records are "Completed". The two tables are related...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.