sql - Need help on a select to gather data from Access database -


Within a PowerShell script,

I need to collect data from the Access database. It is mainly the log of my terminal server : Whenever a person logs on or turns off, a script adds a line in my database with the information below (actually very much but I keep it simple :)).

Here is the database's record:

table log_table

  date_ac Dept User_ac Typeaccess 1/1/2014 dept1 user1 logon 1/1 / 2014 dept3 user2 logon 1 / 1/2014 dept3 user2 logoff 1/1/2014 dept1 user1 logoff 1/1/2014 dept1 user1 logon 1/1/2014 dept1 user1 logoff 2/1/2014 dept1 user1 logon  

I want to group it by the department based on the date of the request, and show the number of different people logged on the basis of that time line (only typeacress logon, not lockoff) one day ( If users are on one day Le loges, then it is counted for one, if he logs for two days, then it is counted for him, but if you log in 20 times

then my example Should be for a request in -1 1/4/2014 -> 2/1/2014:

  • dept1: 2 (user 1 1/1 oh wines but this is only one And once is 2/1 then the total is 2 because this is based on the day)
  • dept3: 1

My problem is that I User name "special Can not get rid of ", such as a user logon should be twice as per my or as one in my total in the form of one.

Currently I tried this:

  SELECT log_table.dept, calculation (log_table.user_ac) AS CountOfuser_ac FROM log_table WHERE (((log_table. [Typeaccess]) = LOGON ') and log_table ( 

This work but this Each user counts the time he logs on.

As required, I like the product here:

  department total nbr user dept1 2 dept3 1  

Collect unique users in each department and day where you department , date_ac and user_ac , then the group that you want to get your desired numbers by the department subquery:

  SELECT t1 [DEPAT], [log_table] from [SELECT [date_ac]], [date_aac], [dpt] [user_ac] from [unique login] as [DEPAT], count (T. [User_ac]] where [type reciper] = 'LOGON '[DTT], [date_AC], [User_ac]) and T1 Group by T1 by [date_ac] # 1/1/2014 # and # 2/1/2014 # Group. [Deep]  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -