Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query/Report problem with specifying criteria 1

Status
Not open for further replies.

neillovell

Programmer
Aug 27, 2002
560
GB
I have a report based upon a query. It asks the user to input 2 dates to sort the records by (it uses BETWEEN).

COST PROJECT HOURS
£130 ProjA Sum: 4.75
Sum: 55%

£100 ProjB Sum: 1.25
Sum: 45%

Anyway the problem is that if ProjA and ProjB both have the same number of hours by them I get the following:

COST PROJECT HOURS
£130 ProjA Sum: 2.10
Sum: 40%
Sum: 2.10
Sum: 40%

The cost field and projB bit go, as does the coloured bar I added to my design.

The SQL for the query looks like:

SELECT ADMINRecordsTable.Project, Sum(ADMINRecordsTable.Hours) AS [Total Project Hours], ADMINEmployeeTable.HourlyWage, (ADMINEmployeeTable.HourlyWage*([Total Project Hours]*24)) AS [Total Cost]
FROM ADMINEmployeeTable, ADMINRecordsTable
WHERE (((ADMINRecordsTable.LogOnName)='emp-three') AND ((ADMINEmployeeTable.LogOnName)='emp-three')) OR (((ADMINRecordsTable.LogOnName)='emp-one') AND ((ADMINEmployeeTable.LogOnName)='emp-one')) OR (((ADMINRecordsTable.LogOnName)='emp-two') AND ((ADMINEmployeeTable.LogOnName)='emp-two'))
GROUP BY ADMINRecordsTable.Project, ADMINEmployeeTable.HourlyWage, ADMINRecordsTable.Date
HAVING (((ADMINRecordsTable.Date) Between [Enter Beginning Date] And [Enter Ending Date]))
ORDER BY ADMINRecordsTable.Project DESC;



 
Hi Neil does this help

Replace your SQL with

SELECT ADMINRecordsTable.Project, Sum(ADMINRecordsTable.Hours) AS [Total Project Hours], ADMINEmployeeTable.HourlyWage, (ADMINEmployeeTable.HourlyWage*([Total Project Hours]*24)) AS [Total Cost]
FROM Total INNER JOIN ADMINEmployeeTable ON ADMINRecordsTable.LogOnName = ADMINEmployeeTable.LogOnName
GROUP BY ADMINRecordsTable.Project, ADMINEmployeeTable.HourlyWage, ADMINRecordsTable.Date
HAVING (((ADMINRecordsTable.Date) Between [Enter Beginning Date] And [Enter Ending Date]))
ORDER BY ADMINRecordsTable.Project DESC;


LEt me know if this works
Rob!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top