sql - Access count on another table doesn't work -
i have posts table , postcomments table of blog system. want count , sort posts comment count query won't work.:
select posts.postid, posts.datecreated, posts.title, posts.description, posts.hits, (select count(commentid) postcomments postcomments.postid=posts.postid , postcomments.isapproved=true) commentcount posts order posts.postid desc;
i tried:
select posts.postid, posts.datecreated, posts.title, posts.description, posts.hits, count([commentid]) commentcount posts inner join postcomments on posts.postid = postcomments.postid;
but have error "you tried execute query not include specified expression 'postid' part of aggregate function."
i'm complete access noob, try second 1 grouping non-aggregated columns.
select posts.postid ,posts.datecreated ,posts.title ,posts.description ,posts.hits ,count([commentid]) commentcount posts inner join postcomments on posts.postid = postcomments.postid group posts.postid ,posts.datecreated ,posts.title ,posts.description ,posts.hits order count([commentid]);
maybe have put join
row braces in ms-access.
Comments
Post a Comment