Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

urgent@@Help in Modify the query Expand / Collapse
Author
Message
Posted Wednesday, October 24, 2012 5:57 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 24, 2014 8:19 PM
Points: 56, Visits: 240
Can any one help with below query. i am getting error saying that

Msg 8120, Level 16, State 1, Line 1
Column 'AEG_DB.dbo.MRO_TBL_EMCData.Application ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.



select [September 2012 Billing File] = CASE WHEN T2.[Application ID] IS NOT NULL AND T2.[ServerName]
IS NOT NULL AND Sum([Billed This Month]) <> 0 THEN 'Y' ELSE 'N' END
FROM [AEG_DB].[dbo].[TBL_Work] T1
LEFT JOIN [TBL_Data] T2 ON (T1.[Application ID] = T2.[Application ID] AND T1.[ServerName] = T2.[ServerName])
WHERE T2.[Data Period] = 'September 2012'
Post #1376734
Posted Wednesday, October 24, 2012 10:20 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 23, 2014 2:53 AM
Points: 1,101, Visits: 5,290
Check the view [TBL_Data]
Post #1376763
Posted Thursday, October 25, 2012 4:41 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 1:37 AM
Points: 997, Visits: 3,089
Try this

SELECT [September 2012 Billing File] = 
CASE
WHEN T2.[Application ID] IS NOT NULL
AND T2.[ServerName] IS NOT NULL
AND SUM([Billed This Month]) <> 0
THEN 'Y'
ELSE 'N'
END
FROM [AEG_DB].[dbo].[TBL_Work] T1
LEFT JOIN [TBL_Data] T2
ON (T1.[Application ID] = T2.[Application ID]
AND T1.[ServerName] = T2.[ServerName])
WHERE T2.[Data Period] = 'September 2012'
GROUP BY T2.[Application ID],
T2.[ServerName];





The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1376906
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse