
select count(*) totmov,usu_usu into #t from comedoc where fec_doc>='20160101' group by usu_usu
order by usu_usu

select key_pri,dbo.f_des_pal(log_usu) log_usu,totmov,dbo.f_des_pal(pas_usu) pas_usu,dbo.f_des_pal(GRU_GRU) GRU_GRU
 from #t join comeusu on #t.usu_usu=comeusu.key_pri
