SQL Queries for massaging original data

The following code was used for cleaning up the original data.
Initially, the plan was to add more mode specific data and thus, three
other data sets were cleaned up. They were not used in the final
version.