oracle 递归查询

1、站点表 lw_sitespa

        站点id            站点名称             站点路径it

        lw_site_id       site_name         static_dirio

2、栏目表 lw_channeldate

        栏目id               站点id        栏目名称  select

  lw_channel_id         lw_site_id     channel_namechannel

3、文章表lw_contentim

    文章id                    栏目id                文章标题                文章发布时间            文章发布状态查询

 lw_content_id       lw_channel_id          article_title               publish_date        publish_statestatic

 

查询站点下,所属栏目为“警务资讯”及其子孙栏目,发布时间在startTime和endTime之间,发布状态不为“09”的文章数量?di

select ls.site_name,ls.static_dir,count(ls.site_name) as total from lw_site ls,

(select ch.lw_channel_id as channelid,ch.lw_site_id as siteid from lw_channel ch start with ch.channel_name ='警务资讯' connect by prior ch.lw_channel_id = ch.parent_id ) tempt,

(select c.lw_channel_id as chnnalid2,c.status as statue from lw_content c where c.publish_date > to_date('"+ startDate +"','yyyy-mm-dd hh24:mi:ss')and c.publish_date < to_date('"+ endDate +"','yyyy-mm-dd hh24:mi:ss')) temp2

where tempt.siteid = ls.lw_site_id

and temp2.chnnalid2 = tempt.channelid and ls.parent_id ='lw_site_id'

and temp2.statue <> '09'

group by ls.site_name,ls.static_dir

order by total desc

相关文章
相关标签/搜索