Demonstrate a bug in the SQL generation of using average with a join that has a condition