Mailing List Archive

Grouping in reports
I'm trying to write a report which will list all tickets, open or
closed, by user. My first attempt looked like this:

SELECT owner AS __group__,
id AS ticket,
time, changetime, component, severity, priority, owner, reporter, cc,
url, version, milestone, status, resolution
FROM ticket
ORDER BY changetime DESC

Unfortunately, the groups don't seem to work properly; groups for each
user appear several times. I initially thought this was only separating
open/closed tickets, so I added WHERE clause:

WHERE status!='closed'

While this eliminated closed tickets, there appears to be a group for
each user on each day. I'll include a sample output:

__group__,ticket,owner,time,changetime,component,severity,priority,reporter,cc,url,version,milestone,status,resolution
uma,6,uma,1086637011,1086637011,Util,normal,normal,cap,None,None,None,None,new,None
uma,5,uma,1086635796,1086635796,CSGA,normal,normal,cap,None,None,None,None,new,None
cap,2,cap,1086557055,1086557824,CS,normal,normal,cap,None,None,None,None,assigned,None
cap,4,cap,1086557416,1086557416,GA,major,normal,cap,tim,None,None,None,new,None
uma,3,uma,1086557162,1086557162,Util,normal,normal,cap,None,None,None,None,new,None

Is my SQL off or is this a bug?

--Cap
Grouping in reports [ In reply to ]
Cap Petschulat wrote:

>SELECT owner AS __group__,
> id AS ticket,
> time, changetime, component, severity, priority, owner, reporter, cc,
>url, version, milestone, status, resolution
> FROM ticket
> ORDER BY changetime DESC
>
>Unfortunately, the groups don't seem to work properly; groups for each
>user appear several times.
>
<snip>

>Is my SQL off or is this a bug?
>
>
Cap, if you add owner to your order by (ahead of changetime), I believe
you'll get what you're looking for.

By the way, were I to use your report on my trac installation, I'd
probably change the owner references above to "upper(owner)" - this is
because otherwise the same text capitalized differently is broken into
separate groups. Ideally of course, all the capitalization would be
consistent. Alas... users. ;-)

-Brian