select c.lcaid,c.comment_id,c.user_id,u.id,c.comment_context,c.user_nick,c.comment_date,u.grade,u.id as grade_id,
a.appname,a.apptype_id,a.icon_addr,a.app_version,
(select count(1) cnt from ams_comment t where t.comment_id <> c.comment_id start with t.comment_id =c.comment_id connect by prior t.comment_id = t.parent_id) cnt
from ams_comment c,view_ams_app a,ams_usergrade u
where c.lcaid=a.lcaid and c.lcaid=u.lcaid(+) and c.USER_ID=u.USER_ID(+) and
(c.parent_id is null or c.parent_id < 1) and appid=19997
order by c.comment_date desc
a.appname,a.apptype_id,a.icon_addr,a.app_version,
(select count(1) cnt from ams_comment t where t.comment_id <> c.comment_id start with t.comment_id =c.comment_id connect by prior t.comment_id = t.parent_id) cnt
from ams_comment c,view_ams_app a,ams_usergrade u
where c.lcaid=a.lcaid and c.lcaid=u.lcaid(+) and c.USER_ID=u.USER_ID(+) and
(c.parent_id is null or c.parent_id < 1) and appid=19997
order by c.comment_date desc