advanced sql almost done