I have a table with a field date_hour - (it dates) and a field nivel_tq -
(integer)
Example:
data_hora nivel_tq
10/10/2003 08:00:00 50
10/10/2003 08:15:00 75
10/10/2003 08:25:00 65
10/10/2003 08:30:00 70
10/10/2003 09:00:00 70
10/10/2003 09:20:00 60
10/10/2003 09:30:00 50
10/10/2003 10:00:00 50
11/10/2003 12:00:00 50
11/10/2003 12:20:00 60
Doubt: I need a select that comes back me the average of the nível_tq
per hour and it dates
the expected result would be:
data_hora nivel_tq
10/10/2003 08:00:00 65
10/10/2003 09:00:00 60
10/10/2003 10:00:00 50
11/10/2003 12:00:00 55select DATEPART(hh,data_hora),sum(nivel_tq)/count(*) as Average from
tablename
group by DATEPART(hh,data_hora)
--
HTH
Ryan Waight, MCDBA, MCSE
"Frank Dulk" <fdulk@.bol.com.br> wrote in message
news:ONYk8cSkDHA.3316@.TK2MSFTNGP11.phx.gbl...
>
>
> I have a table with a field date_hour - (it dates) and a field nivel_tq -
> (integer)
> Example:
> data_hora nivel_tq
> 10/10/2003 08:00:00 50
> 10/10/2003 08:15:00 75
> 10/10/2003 08:25:00 65
> 10/10/2003 08:30:00 70
> 10/10/2003 09:00:00 70
> 10/10/2003 09:20:00 60
> 10/10/2003 09:30:00 50
> 10/10/2003 10:00:00 50
> 11/10/2003 12:00:00 50
> 11/10/2003 12:20:00 60
> Doubt: I need a select that comes back me the average of the nível_tq
> per hour and it dates
> the expected result would be:
> data_hora nivel_tq
> 10/10/2003 08:00:00 65
> 10/10/2003 09:00:00 60
> 10/10/2003 10:00:00 50
> 11/10/2003 12:00:00 55
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment