Friday, March 23, 2012

Grouping by date

Hi,
I need to group the result set on a weekly basis.
The input has only the start date and end date and i need to group the
result on weekly basis...
Thanks in advance for ur advice...I generally do this in the query...
add a column to the select statement
datename( wk,end_date) as Week
then group on that... If you span years add year and week instead of just
week..
Hope this helps...
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"CCP" <CCP@.discussions.microsoft.com> wrote in message
news:338BCC62-7FFA-46B1-ABCE-91EB0C471DD2@.microsoft.com...
> Hi,
> I need to group the result set on a weekly basis.
> The input has only the start date and end date and i need to group the
> result on weekly basis...
> Thanks in advance for ur advice...
>|||Thanks Wayne ,
That really helped me...
now im caught in a new issue.
when i insert a group in the table for the weekenddate.the alternate
coloring of rows has disappeared...
i cant get where im going wrong...
im grouping the record based on the weekend date...
Thanks
"Wayne Snyder" wrote:
> I generally do this in the query...
> add a column to the select statement
> datename( wk,end_date) as Week
> then group on that... If you span years add year and week instead of just
> week..
> Hope this helps...
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "CCP" <CCP@.discussions.microsoft.com> wrote in message
> news:338BCC62-7FFA-46B1-ABCE-91EB0C471DD2@.microsoft.com...
> > Hi,
> > I need to group the result set on a weekly basis.
> > The input has only the start date and end date and i need to group the
> > result on weekly basis...
> >
> > Thanks in advance for ur advice...
> >
> >
>
>

No comments:

Post a Comment