March 22, 2011 at 1:31 pm
I need to create sql statement wherein if I feed the following table fields as input parameters:
Channel_Date, Ch_A, Ch_B, Ch_C, Ch_D
and I also feed @startdate and @enddate params
it will give me Channel_Date values showing every hour on the hour, then each subsequent fields showing AVERAGE val for each given hour (e.g. avg of values from 1:00 thru 1:45). The date value for Channel date currently are on 15-minute intervals e.g. 1/1/2011 1:00 AM, 1/1/2011 1:15, 1/1/2011 1:30.. and so forth.
All field(s) are part of one table being queried. Channel_Date is datetime value, other fields are real datatype vals.
Sample Output:
Channel_Date, Avg_Ch_A, Avg_ChB, ...
1/1/2011 1:00, {avg val), {avg val}
1/1/2011 2:00, {avg val), {avg val}
1/1/2011 3:00, {avg val), {avg val}
Thank you for sharing your expertise.
UPDATE:
After hours and hours of scouring around, the closest solution I found is here:
http://www.sqlservercentral.com/Forums/Topic313278-8-1.aspx
I hope this can help others... Peace
March 27, 2011 at 11:14 pm
Maybe you can use a pivot tables in SQL Server
March 28, 2011 at 12:14 am
Your narrative is great but you might want to check the first link in my signature line below to get better help in the future.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply