Prepare teach data by selecting data from two tables as function of type of work