Selecting Distinct on Two Different Tables

I would like to display in Gridview the following SQL command:

SELECT DISTINCT application_floor .*, application_shift .* FROM application_floor LEFT JOIN application ON application_floor . application_id = application . id LEFT JOIN applicant ON application . applicant_id = applicant . id LEFT JOIN department ON applicant . department_id = department . id LEFT JOIN faculty ON department . faculty_id = faculty . id LEFT JOIN floor ON application_floor . floor_id = floor . id LEFT JOIN building ON floor . building_id = building . id LEFT JOIN application_shift ON application_floor . application_id = application_shift . application_id LEFT JOIN shift ON application_shift . shift_id = shift . id

But distinct() only takes in the arguments true or false. What is the best way to do this?

I’ve changed the query to include a groupBy(), so the query now looks like this:

$ query = ApplicationFloor::find()->joinWith(['application','application.applicant','application.applicant.department','application.applicant.department.faculty', 'floor','floor.building', 'applicationShift', 'applicationShift.shift'])->groupBy(['application_floor.floor_id', 'application_shift.shift_id', 'application_floor.application_id']);

The command being run seems correct:
SELECT COUNT(*) FROM (SELECT application_floor.* FROM application_floorLEFT JOINapplicationONapplication_floor.application_id=application.idLEFT JOINapplicantONapplication.applicant_id=applicant.idLEFT JOINdepartmentONapplicant.department_id=department.idLEFT JOINfacultyONdepartment.faculty_id=faculty.idLEFT JOINfloorONapplication_floor.floor_id=floor.idLEFT JOINbuildingONfloor.building_id=building.idLEFT JOINapplication_shiftONapplication_floor.application_id=application_shift.application_idLEFT JOINshiftONapplication_shift.shift_id=shift.idGROUP BYapplication_floor.floor_id)

But the Gridview is way out of wack and not displaying all the rows, seems to be doing the distinct rows again. Does anyone know how to fix this?