Hey guys,
I have a query request to return all employees who do not have service history. One way I can do this is to look for anyone that has zero months and years of service.
For example, I have this simple query
I ran the query, and was puzzled to find some SSNS that do indeed have service years or months greater than 0. Then it dawned on me that the query was returning any record in the history that had zero value, and the history table contains multiple records for each SSN.
Example
SSN DATE SERVICE YEARS
2345555555 01-01-1992 1
2345555555 01-01-1991 0
This SSN (bogus SSN) would have appeared in my results because there is a zero record for service years.
I don't want this SSN in my query results. I only want people who never had a service year. Can anyone help?
I have a query request to return all employees who do not have service history. One way I can do this is to look for anyone that has zero months and years of service.
For example, I have this simple query
Code:
select distinct SSN from history
where service_years = 0
and service_months = 0.00
I ran the query, and was puzzled to find some SSNS that do indeed have service years or months greater than 0. Then it dawned on me that the query was returning any record in the history that had zero value, and the history table contains multiple records for each SSN.
Example
SSN DATE SERVICE YEARS
2345555555 01-01-1992 1
2345555555 01-01-1991 0
This SSN (bogus SSN) would have appeared in my results because there is a zero record for service years.
I don't want this SSN in my query results. I only want people who never had a service year. Can anyone help?