postgresql7.1
select host_url, count(*) as n_bookmarks
from
(
select o2.bookmark_id, o2.url_id
from bm_bookmarks o1, bm_bookmarks o2
where
o1.parent_id = :root_folder_id
and o2.tree_sortkey between o1.tree_sortkey and tree_right(o1.tree_sortkey)
) b join bm_urls using (url_id)
where acs_permission__permission_p(b.bookmark_id, :browsing_user_id, 'read') = 't'
group by host_url
order by n_bookmarks desc
select complete_url as local_title,
complete_url, count(*) as n_bookmarks
from
(
select o2.bookmark_id, o2.url_id
from bm_bookmarks o1, bm_bookmarks o2
where
o1.parent_id = :root_folder_id
and o2.tree_sortkey between o1.tree_sortkey and tree_right(o1.tree_sortkey)
) b join bm_urls using (url_id)
where acs_permission__permission_p(b.bookmark_id, :browsing_user_id, 'read') = 't'
group by complete_url, local_title
order by n_bookmarks desc