Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL help...

Author  Topic 

Makaio780
Starting Member

24 Posts

Posted - 2012-02-13 : 17:20:00
How come i can't add derivedtbl_1.expr1 as a aggrate funtions of a group by clause?

Select count(vars75_hpd_help_desk_1.incident_number)as tktcount,Month(Reported_date) as mth,derivedtbl_1.expr1
from vars75_hpd_help_desk as vars75_hpd_help_desk_1 inner join
vTbl_ServiceDeskAnalystList ON vARS75_HPD_Help_Desk_1.Owner = vTbl_ServiceDeskAnalystList.[Full Name] CROSS JOIN
(SELECT COUNT(Incident_Number) AS Expr1
FROM vARS75_HPD_Help_Desk
WHERE (Assigned_Group = 'HD-Edmonton' OR
Assigned_Group = 'HD-Edmonton-1.5') AND (Reported_Source = 'Phone') AND (Last_Resolved_Date <= DATEADD(ss, 3600, Reported_Date)) AND
(Reported_date > dateadd(mm,datediff(mm,0,getdate())-12,0))
and ( Reported_date < dateadd(month, datediff(month, 0, getdate()), 0))) AS derivedtbl_1
where reported_Source = 'phone' and (Reported_date > dateadd(mm,datediff(mm,0,getdate())-12,0))
and ( Reported_date < dateadd(month, datediff(month, 0, getdate()), 0))
group by month(reported_date)

Ron Cheung

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-02-13 : 18:23:49
What do you mean by "can't?" Is an error generated?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-13 : 18:35:49
quote:
Originally posted by Makaio780

How come i can't add derivedtbl_1.expr1 as a aggrate funtions of a group by clause?

Select count(vars75_hpd_help_desk_1.incident_number)as tktcount,Month(Reported_date) as mth,derivedtbl_1.expr1
from vars75_hpd_help_desk as vars75_hpd_help_desk_1 inner join
vTbl_ServiceDeskAnalystList ON vARS75_HPD_Help_Desk_1.Owner = vTbl_ServiceDeskAnalystList.[Full Name] CROSS JOIN
(SELECT COUNT(Incident_Number) AS Expr1
FROM vARS75_HPD_Help_Desk
WHERE (Assigned_Group = 'HD-Edmonton' OR
Assigned_Group = 'HD-Edmonton-1.5') AND (Reported_Source = 'Phone') AND (Last_Resolved_Date <= DATEADD(ss, 3600, Reported_Date)) AND
(Reported_date > dateadd(mm,datediff(mm,0,getdate())-12,0))
and ( Reported_date < dateadd(month, datediff(month, 0, getdate()), 0))) AS derivedtbl_1
where reported_Source = 'phone' and (Reported_date > dateadd(mm,datediff(mm,0,getdate())-12,0))
and ( Reported_date < dateadd(month, datediff(month, 0, getdate()), 0))
group by month(reported_date),derivedtbl_1.expr1

Ron Cheung



you're missing it from group by

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -