Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 creating a stored procedure

Author  Topic 

bhushanm
Starting Member

3 Posts

Posted - 2007-10-03 : 01:56:58
i have a table as:

activity_id | casenum | audit_time | username | result

1 1 9/28/2007 10:00:00 AM orderful 400
2 1 9/28/2007 11:00:00 AM bell rejected
1 1 9/28/2007 11:13:25 AM orderful 200
1 2 9/28/2007 1:00:25 PM orderful 300
2 2 9/28/2007 3:00:25 PM bell accepted
1 3 9/28/2007 3:05:25 PM orderful 500
2 3 9/28/2007 3:13:25 PM george accepted
2 1 9/28/2007 3:25:12 PM bell approved


i want to write an stored procedure which will compute the maximum, minimum, avg time taken by each user to complete an activity(ie time between activity 1 and 2).

the stored procedure should retrun a result set as
username | avg time | min time | max time

can anybody help me in this.

regards,

bhushan

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2007-10-03 : 02:21:49
have you written any queries that get you part of the way there or are you totally stuck? is the homework?



-ec
Go to Top of Page

bhushanm
Starting Member

3 Posts

Posted - 2007-10-03 : 02:51:01
actually i dont know how to create a result set and return it from the stored procedure.

regards,

bhushan
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2007-10-03 : 02:55:28
quote:
Originally posted by bhushanm

actually i dont know how to create a result set and return it from the stored procedure.



don't worry about the resultset from the sproc yet. Have you come up with your sql query that returns what you are looking for? if so, paste that here and we can show you how to make it into a sproc.



-ec
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-03 : 04:17:15
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -