Forse dovresti usare group by categoria, ma credo che nn sia questa la sezione giusta del forum