[thelist] SQL Problem
rudy
r937 at interlog.com
Sun May 6 19:59:49 CDT 2001
> I don't know whether creating a view for each day
> would be a good idea
no, create only one view, which extracts the day part of the date
a view, by the way, is just a definition, it is not a physical extract
it's just another way to give a "column name" to an expression -- and you
can then more readily group by that column
create view dayonly (theday, value)
as
select convert(char(10),timestamp,102), value
from yourtable
the view "looks like" a table because it has two columns called theday and
value (but don't use the name value, okay?)
then you just run your query on the view
you do have to use group by, because you are grouping several rows that all
have the same day, and getting the average of another column for each group
select theday, avg(value)
from dayonly
group by theday
try it, you'll like it, and it's just as fast as a query
rudy
More information about the thelist
mailing list