[rt-users] Report "Resolved by owner" fails to output, generates error in log

John Hascall john at iastate.edu
Thu Apr 16 09:54:09 EDT 2009



> SELECT COUNT(main.id) AS id,
>            Users_2.Name AS col1
> FROM Tickets main
> LEFT JOIN Users Users_2  ON ( Users_2.id = main.Owner )
> LEFT JOIN Users Users_1  ON ( Users_1.id = main.Owner ) 
> WHERE (main.Status != 'deleted')
>   AND (main.Status = 'resolved' AND main.Queue = '5')
>   AND (main.Type = 'ticket')
>   AND (main.EffectiveId = main.id) 
> GROUP BY Users_2.Name;

While we are looking at this query,
it seems to me that the first where clause is
made redundant by the second one:

> WHERE (main.Status != 'deleted')
>   AND (main.Status = 'resolved' AND main.Queue = '5')

If (main.Status = 'resolved' AND main.Queue = '5')
then it must be true that (main.Status != 'deleted')

And I don't see any use of the Tickets table.
Also, where is the 2nd left join used?
Thus:

> SELECT COUNT(main.id) AS id,
>            Users.Name AS col1
> FROM main
> LEFT JOIN Users ON ( Users.id = main.Owner )
> WHERE (main.Status = 'resolved')
>   AND (main.Queue = '5')
>   AND (main.Type = 'ticket')
>   AND (main.EffectiveId = main.id) 
> GROUP BY Users.Name;

would seem to be a lot simpler.
Or have I overlooked something obvious?

John



More information about the rt-users mailing list