/* Count the most popular keyword for each slot */ select kslot, kwdid into #s from METAkwd, METAcat where METAkwd.catid = METAcat.catid and METAcat.catid > 0 and kwdid != -140 go select kslot, kwdid, n = count(*) into #u from #s group by kslot, kwdid go select kslot, m=MAX(n), n=SUM(n) into #m from #u group by kslot go select #u.kslot, name, #m.n, c=(100*#m.m)/#m.n from #m , #u, METAkwdef where #m.kslot = #u.kslot and #m.m = #u.n and #u.kwdid = METAkwdef.kwdid order by #u.kslot go