You are here: Re: Dynamic date range for each row? « MsSQL Server « IT news, forums, messages
Re: Dynamic date range for each row?

Posted by Gert-Jan Strik on 01/30/08 19:30

jefftyzzer wrote:
>
> On Jan 29, 10:46 am, "lee.richmond" <Richm...@gmail.com> wrote:
> > Hi,
> >
> > I'm trying to group data by date range, but each row of data could
> > have a different date range based on a variable.
> >
> > I want to say "look at the date range the paste five orders were
> > placed" for each row individually. As an example, think of the rows as
> > keywords in a Search Marketing program. Keyword X had 5 orders placed
> > in the last week, Keyword Y had 5 orders placed in the last 2 weeks. I
> > want each keyword to display its average impressions over the course
> > of its respective date range.
> >
> > Is this possible?
> >
> > Thanks in advance!
>
> Lee,
>
> If (your version of) SQL Server implements them, you may want to look
> at the windowing functions, and specifically the framing clause.
> Here's an example of a simple moving average:
>
> SELECT
> keyword,
> avg(qty) over (order by orderdate range between 5 preceding and
> current row) as n
> from
> orders
>
> The important part is the "range between 5 preceding and current row"
>
> --Jeff

Jeff,

According to SQL Server 2005's Books Online, aggregate window functions
only support partitioning by a column. IOW, AFAIK SQL Server does not
(yet?) support PRECEDING or CURRENT ROW as windowing selectors.

--
Gert-Jan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация