若是主题帖,则tid=id
若是回复贴,则tid!=id

解决方案 »

  1.   

    with Args as
    (
    select * from post
    union all 
    select * from post where post.id  = Args.id
    )
    select * ,row_number over(order by id) from Args ;
      

  2.   

    贴子没有父ID时,它的TID值是什么,你怎么定义的,是NULL还是它的ID本身?
      

  3.   

    若是主题帖,则tid=id 
    若是回复贴,则tid!=id
      

  4.   

    select * ,(select count(1) from post where tid=a.id and tid<>id ) 回复数 from post a where id=tid order by dateline desc
      

  5.   

    --如果你的主题帖也算回复数的话。
    --看你要哪个?
    select * ,(select count(1) from post where tid=a.id) 回复数 from post a where id=tid order by dateline desc