vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | for $event in dataset('Event') |
| 2 | for $sponsor in $event.sponsoring_sigs |
| 3 | let $es := { "event": $event, "sponsor": $sponsor } |
| 4 | group by $sig_name := $sponsor.sig_name with $es |
| 5 | let $sig_sponsorship_count := count($es) |
| 6 | let $by_chapter := |
| 7 | for $e in $es |
| 8 | group by $chapter_name := $e.sponsor.chapter_name with $es |
| 9 | return { "chapter_name": $chapter_name, "escount" : count($es) } |
| 10 | order by $sig_sponsorship_count desc |
| 11 | limit 5 offset 2 |
| 12 | return { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter } |