Computing.Net > Forums > Database > sql find totalprocess time of doc

sql find totalprocess time of doc

Reply to Message Icon

Original Message
Name: SherrySun
Date: August 15, 2006 at 07:44:27 Pacific
Subject: sql find totalprocess time of doc
OS: windows xp
CPU/Ram: centrino
Model/Manufacturer: IBM
Comment:

hi,
I need help on making a SQL query to find the total processing time of a document by each user by each day. The database is SQL server 2000. The original table is like:
userid docid actiontime action
A 111 8/15/06 8:00am delivered
A 111 8/15/06 9:00am approved
B 111 8/15/06 9:00am delivered
B 111 8/15/06 9:30am rejected
A 111 8/15/06 9:30am delivered
A 111 8/15/06 11:00am approved
B 111 8/15/06 11:00am delivered
B 111 8/15/06 11:10am approved
A 112 8/15/06 8:00am delivered
A 112 8/15/06 8:15am approved


The report should look like:

date userid doc# totaltime(mins)
8/15/06 A 2 165
8/15/06 B 1 40

For 8/15/06, user A processed 2 documents which is 111 and 112, user B processed 1 document. The report need to calculate each time range from delivered to approved, or from delivered to rejected,then add them together for each user by each day.

So far, I can use the MAX(ActionTime),MIX(ActionTime), then use DATEDIFF(minute, MIN(ActionTime), MAX(ActionTime)) for user B, group by docid,But for user A, any one can help me? Thanks ahead!

Sincerely
Sherry



Report Offensive Message For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: sql find totalprocess time of doc

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software