SQL query help

K

Kappa

I've a table Client_Table like this

Company_Id - User_Id - Account_Delete_Date

ABC - u001 - 01/03/2005
ABC - u002 -
XYZ - u020 - 02/02/2007
XYZ - u050 - 04/03/2008
XYZ - u060 -

Date can by anywhere between Jan 2005 to Aug 2008.

Q: Can you please tell me what query I need to write to get total
number of active users in each month (of 2005 to 2008) for a
particular company. I have Account Delete Date, from where I can
determine if user is active or not.

So I have to count how many User_Ids (for a particular company) are
not deleted in a particular month.

Result would be something like this:

Company_Id : Jan 2005 : Feb 2005 : March 2005 ......................
Aug 2008
ABC : 2 : 1 :
3 ...................... 3
XYZ : 4 : 5 :
2 ...................... 8

Thanks a lot in advance.
 
K

KARL DEWEY

There is not enough information.
We do not know how many users there were for each company at the start.
We do not know if or when other may have joined a company.
 
K

Kappa

There is not enough information.  
We do not know how many users there were for each company at the start.
We do not know if or when other may have joined a company.

Users (us001, etc) can be counted against each company. If delete date
is empty it means account is still active.

and why do we need a join date for?
 
L

Lord Kelvan

you need the start date to determine when the user was added to that
table unless all users were added in 2005 and none have been added
since because a user could be added in 2007 you dont want him
appearing in 2005 because he wasnt a user at that date

if you dont have a date for when the user was created then you wont
get accrucate information unless all users were added in 2005
 
K

KARL DEWEY

The only way I can think of is to use the Sorting and Grouping to group on
employee (employee information in header), group on action item (action items
in group header), and projects in details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top