Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need a rolling count of rows from table using just SQL

tx103108Jan 10 2014 — edited Jan 13 2014

Oracle 11gR2

RHEL 6.4

---------------

Given the following table data:

EMPLOYEE     HIRE_DATE     TERM_DATE     DEPT

------------------     -----------------     ------------------      ---------

John Doe          01/01/13                                   101

Jane Smith       01/05/13                                   102

Bob Jones        02/04/13          04/22/13             102

Jenny Boo        03/12/13          03/31/13             103

Joe Schmoe     03/24/13                                    102

Bill Max            04/23/13                                   103

Jill Clay            04/24/13                                   103

Joe Boom         05/11/13                                   102

I want to return the number of employees that are still employed for each month so long as they were hired anytime in that month and irregardless if they were terminated later that month (i.e only the month concerns me).  So I would be expecting

MONTH  EMPLOYEES

Jan         2

Feb        3

Mar        5

Apr        6   (Jenny Boo has been terminated)

May       6   (Jenny Boo and Bob Jones have been terminated)  

I know there are some bright people out there that are SQL experts but I am not one of them.  If there is a way to do this in just SQL I would like to see it.

This post has been answered by unknown-7404 on Jan 12 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2014
Added on Jan 10 2014
11 comments
753 views