Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Get the average of the data in the table. Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, October 15, 2012 7:23 PM
 SSC Rookie Group: General Forum Members Last Login: Wednesday, February 05, 2014 10:27 AM Points: 31, Visits: 374
 Team, I have a set of data for perticular day.Plesae help me in writing a sql query to get the average of the data for perticular day.Table:Day valuejune 1 4june 1 5june 1 2june 2 1june 2 5june 2 3Ouput needed as below:day avg valueJune 1 3.6june 2 3As above i need a calculated average result for all the data for a perticualr day.Thanks in advance.
Post #1373009
 Posted Monday, October 15, 2012 10:18 PM
 SSC Rookie Group: General Forum Members Last Login: Wednesday, February 27, 2013 6:54 AM Points: 40, Visits: 168
 Try:`select [Day], AVG([Value] as Avg_Valuefrom [MyTable]group by [Day]`Hope this helps. http://www.imoveisemexposicao.com.br
Post #1373022
 Posted Monday, October 15, 2012 10:26 PM
 SSC Eights! Group: General Forum Members Last Login: Thursday, March 13, 2014 3:40 AM Points: 880, Visits: 668
 try below code.....declare @t1 table (day varchar(10),value int)insert into @t1select 'june 1',4union allselect 'june 1',5union allselect 'june 1',2union allselect 'june 2',1union allselect 'june 2',5union allselect 'june 2',3select [Day], AVG(convert(decimal(10),[Value])) as avfrom @t1group by [Day]
Post #1373023

 Permissions