Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL question: least and most employed in a given period

Status
Not open for further replies.

pusakat

Programmer
Jan 6, 2009
1
US
Hi,

My SQL knowledge is awfully rusty and I need help on the following:


Table: EMPLOYEE_TBL
Columns: ID_NUMBER, HIRE_DATE, TERMINATION_DATE

-HIRE_DATE, TERMINATION_DATE are both Dates

I need a SQL statement gets the least and most number of employees employed in a given period (START_DATE & END_DATE). I don't need the exact day/s where there least and most are found just the counts.

Any form of help is appreciated.

Thanks!!!!
 
to begin with, you will need some way to generate each individual date between the start and end dates, so that the query can do a count of employees on each individual date

what database system are you using? you will get a better answer if you ask in the appropriate forum

ANSI SQL date handling very rarely works in specific database systems

r937.com | rudy.ca
 
I think you said, who come and go the most/least.

Select ID_NUM, MIN(CNT), MAX(CNT) FROM

(select ID_NUM, count(*) as cnt) AS B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top