Alias calculation with table aliases, fixes #326