查無關鍵字統計報表

create or replace procedure P_114_SEARCHNT(
                                          o_Cursor    Out Pack_Service.t_Retdataset,
                                          i_Begindate    In varchar2, -- 開始時間
                                          i_Enddate      In varchar2, -- 結束時間
                                          i_citycode     In varchar2 -- 地址代碼
                                          )
/********************************************
       功能:查無關鍵字統計報表(詳單)
       作者:FC
       日期:2013-03-20
*********************************************/
 is
 v_Begindate Date := to_Date(i_Begindate, 'yyyy-mm-dd');
 v_Enddate   Date := to_Date(i_Enddate, 'yyyy-mm-dd');
 v_citycode  varchar2(20) := substr(i_citycode, 0, Instr(i_citycode, '|') - 1);
 
begin
  if v_citycode is null then
    v_citycode := i_citycode;
  end if;
 
  open o_Cursor for
  select Keyword, count(1) as Searchtime, Searchcyc, Cityname
    from (
          select case
                    when t.title is null then
                     replace(replace(replace(t.content, '查詢條件', ''), ':', ''), ' ', '')
                    else
                      replace(replace(replace(t.title, '查詢條件', ''), ':', ''), ' ', '')
                  end as Keyword,
                 
                  i_Begindate || '至' || i_Enddate as Searchcyc,
                  c.cityname as Cityname
            from T_WORKSHEET_LOG t, T_CITIES c
           where t.citycode = c.citycode
             and t.handledate >= v_Begindate
             and t.handledate < v_Enddate
             and t.action = 'A'
             and (t.citycode = v_citycode or 'gz' = v_citycode))
   group by Cityname, Keyword, Searchcyc;
 
 
end P_114_SEARCHNT;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章