Adam McReynolds
Registered User.
- Local time
- Today, 02:03
- Joined
- Aug 6, 2012
- Messages
- 129
I have 2 tables: one for repairs and the other for the billing for those repairs. There is a foreign key(record_num) in the billing table to match the primary key(prikey) in the repairs table. This works fine as long as the unit repair has been completed.
Now an employee wants to see records even if they are not completed and wants the rate to be $0.00 if the unit has not been completed. But by this method there is no record in the billing table.
My problem is if I have the 2 tables joined then I only see records that match both tables. Any help or direction would be awesome!
Here is my SQL for the query:
Now an employee wants to see records even if they are not completed and wants the rate to be $0.00 if the unit has not been completed. But by this method there is no record in the billing table.
My problem is if I have the 2 tables joined then I only see records that match both tables. Any help or direction would be awesome!
Here is my SQL for the query:
Code:
SELECT DISTINCTROW tbl_module_repairs.end_user, tbl_module_repairs.pickup_date, tbl_module_repairs.complete_date, IIf([pickup_entity]="Storm","APS Storm","APS Field Tech") AS [Repair Pickup], tbl_module_repairs.mfg_part_num, tbl_module_repairs.manufacturer, tbl_module_repairs.module_type, tbl_module_repairs.incoming_module_sn, IIf([incoming_disposition]="Warranty","Warranty",IIf([incoming_disposition]="BER","BER",IIf([incoming_disposition]="Completed","Standard","N/A"))) AS [Repair Type], tbl_module_repairs.problem_description, tbl_module_repairs.work_comments, IIf(IsNull([complete_date]),"Unit Not Completed ",DateDiff("d",[pickup_date],[complete_date])) AS [Turnaround Time], tbl_module_repairs_captured_data.Rate
FROM tbl_module_repairs INNER JOIN tbl_module_repairs_captured_data ON tbl_module_repairs.prikey = tbl_module_repairs_captured_data.record_num
WHERE (((tbl_module_repairs.pickup_date) Between [Enter Start Date] And [Enter End Date] And (tbl_module_repairs.pickup_date) Is Not Null And (tbl_module_repairs.pickup_date)>#1/1/2014#) AND ((tbl_module_repairs.complete_date) Is Not Null) AND ((tbl_module_repairs.prikey) Is Not Null) AND ((tbl_module_repairs.customer)="Cox SD" Or (tbl_module_repairs.customer)="Cox NC" Or (tbl_module_repairs.customer)="Cox OC" Or (tbl_module_repairs.customer)="Cox SB" Or (tbl_module_repairs.customer)="Cox PV"))
ORDER BY tbl_module_repairs.pickup_date;