Database How Would I Achieve This Using Sql Or Bigquery Sql

Database How Would I Achieve This Using Sql Or Bigquery Sql