braintec interview question

Join tables sql - needed to create a query