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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Syntax errors on my complex query - please help
 Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

Flowing Fount of Yak Knowledge

1836 Posts

Posted - 02/18/2010 :  14:15:44  Show Profile  Reply with Quote
Np. You're welcome. Please make sure to give as much info as possible so tht you can get quicker solutions.
Go to Top of Page


United Kingdom
22859 Posts

Posted - 02/18/2010 :  14:16:22  Show Profile  Reply with Quote

SELECT	rep_Id, 
	post, Dept, sDate, eDate, 
	NumPeopleGo, NoEvals, 
	CAST((NumPeopleGo * NumPeopleGo) AS Integer)
Square of NumPeopleGo or possible column name error?

		+ COALESCE(SUB_TOTAL, 0) AS NoRequired
	SELECT DISTINCT qry_reports.rep_Id,, qry_reports.Dept, qry_reports.sDate, qry_reports.eDate, 
	qry_reports.NumPeopleGo AS NumPeopleGo, 
NumPeopleGo is aliased as the same name - possibly related to my point above?

		SELECT	SUM(qry_reports_2.NumPeopleGo) 
		FROM	qry_reports AS qry_reports_2
		WHERE	qry_reports_2.rep_Id = qry_reports.rep_Id 
			AND qry_reports_2.Dept <> qry_reports.Dept
		GROUP BY qry_reports_2.rep_Id
	CAST((NumPeopleGo * NumPeopleGo) AS Integer)
Square of NumPeopleGo again (or possible column name error)

		+ COALESCE(SUB_TOTAL, 0) AS NoRequired
	FROM qry_reports 
	LEFT JOIN qry_reports AS qry_reports_1 
		ON qry_reports.rep_Id = qry_reports_1.rep_Id
Left Join to the same table on the same key - its going to just get the same row from the same table, isn't it?

) AS T

Edited by - Kristen on 02/18/2010 14:18:38
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000