techwriterAR
MIS
I have a Crystal 8.5 report that calculates the number of days an employee has worked in a department. The MS-SQL table has fields for employee number, employee status, date in, date out, department. I can use either the formula or the SQL expression listed below and arrive at the correct number of days for each record.
The problem is that some employees have gone back and forth between departments and have more than one set of date in and date out records in a department. The report needs to show a total for all days worked in a particular department for each employee, not separate records by employee. I tried grouping by employee and adding a summary total. However, I do not want the total to display below the employee information. I tried to add Sum to the front of the SQL expression but get an error message and Crystal Reports locks up.
(The error messages are: ODBC error:[Microsoft][ODBC SQL Server Driver][SQL server]Column ‘Dpt_Mbrs.dpt’ is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.” “Error detected by database DLL.”)
I understand what the error message is telling me, I just do not know how to fix it, as I am not using an SQL statement as the basis for the report.
I need to know if there is a way to get a total for all the days worked in a department by employee.
-------------------------------------------------
Either of these will calculate number of days in department for each record:
Formula:
datetimevar start:={DPT_MBRS.DATE_IN};
datetimevar end;
if isnull({DPT_MBRS.DATE_OUT}) then
end:= CurrentDate
else
end:={DPT_MBRS.DATE_OUT};
datediff('d',start,end);
SQL expression:
datediff(d, DPT_MBRS."DATE_IN", ISNULL(DPT_MBRS."DATE_OUT", getdate()))
---------------------------------------------
BTW: the formula listed above came from noxum and the SQL expression was supplied by synapsevampire from a previous posting (May 20, 2003.)
Thanks in advance for any and all help,
gjeffcoat
The problem is that some employees have gone back and forth between departments and have more than one set of date in and date out records in a department. The report needs to show a total for all days worked in a particular department for each employee, not separate records by employee. I tried grouping by employee and adding a summary total. However, I do not want the total to display below the employee information. I tried to add Sum to the front of the SQL expression but get an error message and Crystal Reports locks up.
(The error messages are: ODBC error:[Microsoft][ODBC SQL Server Driver][SQL server]Column ‘Dpt_Mbrs.dpt’ is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.” “Error detected by database DLL.”)
I understand what the error message is telling me, I just do not know how to fix it, as I am not using an SQL statement as the basis for the report.
I need to know if there is a way to get a total for all the days worked in a department by employee.
-------------------------------------------------
Either of these will calculate number of days in department for each record:
Formula:
datetimevar start:={DPT_MBRS.DATE_IN};
datetimevar end;
if isnull({DPT_MBRS.DATE_OUT}) then
end:= CurrentDate
else
end:={DPT_MBRS.DATE_OUT};
datediff('d',start,end);
SQL expression:
datediff(d, DPT_MBRS."DATE_IN", ISNULL(DPT_MBRS."DATE_OUT", getdate()))
---------------------------------------------
BTW: the formula listed above came from noxum and the SQL expression was supplied by synapsevampire from a previous posting (May 20, 2003.)
Thanks in advance for any and all help,
gjeffcoat