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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select records not present.... 1

Status
Not open for further replies.

MichaelNZQA

IS-IT--Management
Jun 16, 2003
15
0
0
NZ
All

I wish to write a Crystal Report that will return Staff records that have not enetered a transaction between two given dates. If I was to write it in SQL it may look like;
=======================================================
select full_name from staff
where staff_ref not in
(select staff_ref from worktrans
where tran_date > 'Sep 2 2003 12:00AM'
and tran_date < 'Sep 15 2003 12:00AM' )
=======================================================

I would also like to make the TRAN_DATE parameter driven. I was succesful with a complete left-joined listing, that grouped all transaction values then surpressed other than 0. But it failed when I entered the Date Parameters.

Any thoughts?

Regards

Michael.


 
I believe it is a matter of Record Selection. You can also the select wizard to replicate this SQL.

Frank
 
Have you created a date range parameter? If you go to report->edit selection formula->record and enter the following formula:

{Tran_date} in {?DateRangeParm}



Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
I would approach this by using a left join from the staff table to the worktrans table. However, do not use a date select on worktrans, since this will, in essence, make your left join an equal join. Instead, create a formula {@workinrange} and place it in the details section:

if isnull({worktrans.date}) or
not({worktrans.date} in {?startdate} to {?enddate}) then
0 else 1

Then group on {staff.staff_ref} and go to report->edit selection formula->GROUP and enter:

sum({@workinrange},{staff.staff_ref}) = 0

This should give you a list of staff who did not work during the specified date range.

-LB
 
lbass

This was indeed a top answer. Worked just perfectly.

Regards

MichaelNZQA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top