All pastes #284425 Raw Edit

Someone

public text v1 · immutable
#284425 ·published 2006-12-19 02:00 UTC
rendered paste body
DELIMITER $$;

DROP PROCEDURE IF EXISTS `devzone`.`sp_view_tag_cloud`$$

CREATE PROCEDURE `sp_view_tag_cloud`(IN row_count bigint)
BEGIN
SET @query = 'select *
  from (select sum(a.total) as total_hits,
               count(*) as total_articles, 
               t.name, 
              (sum(a.total) / count(*)) AS `ratio`
          from (select count(*) as total, 
                       node_id 
                  from devzone_mint.mint_visit 
                       group by node_id) a, 
                       node_tags nt, 
                       tags t              
         where a.node_id = nt.node_id and
               nt.tag_id = t.id       and
              (t.ignore_for_cloud = 0 and 
               t.hidden = 0           and
               t.category = 0)
         group by tag_id
         order by ratio desc
         limit 0, ?) b
  order by name;';
prepare qry from @query;
SET @v = row_count;
EXECUTE qry USING @v;
END$$

DELIMITER ;$$