renee35
MIS
- Jan 30, 2007
- 199
Hello,
I am trying to create a report that gets me a count of orders created per week. I have the below query so far, but keep getting an error that states "GROUP BY expressions must refer to column names that appear in the select list."
I am a newbie to this and would greatly appreciate some help on how to make this query work. What I am trying to achieve is below:
select
datename(year,getdate()) +'-'+right('00' + cast(datepart(week,getdate()) as varchar),2),
dateadd(day,2-datepart(weekday,TODO_PLAN_START_DT),datediff(day,0,TODO_PLAN_START_DT)), 2-datepart(weekday,TODO_PLAN_START_DT),
COUNT (OPTY_ID)
as 'Net New'
From
(
Select
'Start' = min (TODO_PLAN_START_DT), OPTY_ID
From S_EVT_ACT
where TODO_CD='Onsite Demo' and
TODO_PLAN_START_DT between '04/01/06' and '03/31/2008'
GROUP BY OPTY_ID
)
as Mtgs
GROUP BY datename(year,getdate()) +'-'+right('00' + cast(datepart(week,getdate()) as varchar),2),
dateadd(day,2-datepart(weekday,TODO_PLAN_START_DT),datediff(day,0,TODO_PLAN_START_DT)), 2-datepart(weekday,TODO_PLAN_START_DT)
Thanks a bunch!!
Thanks a bunch!!
-T
I am trying to create a report that gets me a count of orders created per week. I have the below query so far, but keep getting an error that states "GROUP BY expressions must refer to column names that appear in the select list."
I am a newbie to this and would greatly appreciate some help on how to make this query work. What I am trying to achieve is below:
select
datename(year,getdate()) +'-'+right('00' + cast(datepart(week,getdate()) as varchar),2),
dateadd(day,2-datepart(weekday,TODO_PLAN_START_DT),datediff(day,0,TODO_PLAN_START_DT)), 2-datepart(weekday,TODO_PLAN_START_DT),
COUNT (OPTY_ID)
as 'Net New'
From
(
Select
'Start' = min (TODO_PLAN_START_DT), OPTY_ID
From S_EVT_ACT
where TODO_CD='Onsite Demo' and
TODO_PLAN_START_DT between '04/01/06' and '03/31/2008'
GROUP BY OPTY_ID
)
as Mtgs
GROUP BY datename(year,getdate()) +'-'+right('00' + cast(datepart(week,getdate()) as varchar),2),
dateadd(day,2-datepart(weekday,TODO_PLAN_START_DT),datediff(day,0,TODO_PLAN_START_DT)), 2-datepart(weekday,TODO_PLAN_START_DT)
Thanks a bunch!!
Thanks a bunch!!
-T