SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Select Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

eljapo4
Yak Posting Veteran

United Kingdom
94 Posts

Posted - 04/26/2012 :  11:30:06  Show Profile  Reply with Quote
Hi - I have to separate jobs but I want to sum the total minutes spent for both jobs, the D1_Factor_PC is different for the 2 jobs my query is returning me 2 rows instead of one can anyone help please?
SELECT 	SUM(dbo.tbl_Daily_Timesheet.EffectiveMinutes * D1_Factor_PC)/100 [Personal Needs RECOVERY]
FROM dbo.tbl_Daily_Timesheet 
INNER JOIN dbo.tbl_Job_D1_Factors ON dbo.tbl_Daily_Timesheet.WorkstudyCode = dbo.tbl_Job_D1_Factors.Job_Code 
INNER JOIN dbo.tbl_D1_Factors ON dbo.tbl_Job_D1_Factors.D1_Factor_ID = dbo.tbl_D1_Factors.D1_Factor_ID 
WHERE tbl_Job_D1_Factors.D1_Factor_ID = '1'  --Personal Needs 
GROUP BY dbo.tbl_Daily_Timesheet.EffectiveMinutes
		,dbo.tbl_Job_D1_Factors.D1_Factor_PC

Edited by - eljapo4 on 04/26/2012 11:31:48

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 04/26/2012 :  11:34:38  Show Profile  Reply with Quote
Remove the grouping
SELECT
	SUM(dbo.tbl_Daily_Timesheet.EffectiveMinutes * D1_Factor_PC) / 100 
	[Personal Needs RECOVERY]
FROM
	dbo.tbl_Daily_Timesheet
	INNER JOIN dbo.tbl_Job_D1_Factors
		ON  dbo.tbl_Daily_Timesheet.WorkstudyCode = dbo.tbl_Job_D1_Factors.Job_Code
	INNER JOIN dbo.tbl_D1_Factors
		ON  dbo.tbl_Job_D1_Factors.D1_Factor_ID = dbo.tbl_D1_Factors.D1_Factor_ID
WHERE
	tbl_Job_D1_Factors.D1_Factor_ID = '1' --Personal Needs

Edited by - sunitabeck on 04/26/2012 11:35:34
Go to Top of Page

eljapo4
Yak Posting Veteran

United Kingdom
94 Posts

Posted - 04/26/2012 :  11:49:10  Show Profile  Reply with Quote
Thank you sunitabeck
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  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.06 seconds. Powered By: Snitz Forums 2000