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
 Other Forums
 Other Topics
 Help with SQL code for another program

Author  Topic 

vpillai
Starting Member

3 Posts

Posted - 2012-03-13 : 11:40:14
Hello,

I'm trying to write a SQL code for a program that uses SQL. I'm trying to calculate the average of the recovery lengths and the average of the depths for 5 runs (R-1 to R-5, R-6 to R-10 etc) at a time (without weighting it). For example, I need the average of the recovery lengths and depth corresponding to Run numbers R-1 to R-5. I've included an image below.



The table is called SAMPLE. I would like to display only the averages and I want to do this without adding additional columns to the table.

Please let me know. Any kind of help would be appreciated. Thanks.
Vinod

webguru11
Starting Member

2 Posts

Posted - 2012-04-10 : 07:36:59
It would be a very long code.. You can mail me I'll help you there.

Website Design Company | Web Design | SEO Services Company India | Logo Design Company
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-04-10 : 12:08:23
[code]SELECT Avg(depth) as avgDepth,
Avg(RecoveryLength) as avgRecoveryLength
FROM YourTable
WHERE Convert(int, Replace([number], 'R-', '')) BETWEEN 1 and 5[/code]
Go to Top of Page
   

- Advertisement -