The count is always 1, but what I need to get is the count or the number of news under each category. Like category Sport has 2 news and category Technology has 4 news:
select
News.NewsId, News.NewsTitle,
COUNT(News.NewsId) as Total
from
News
group by
News.NewsId, News.NewsTitle
inner join
NewsCategory on News.NewsId = NewsCategory.NewsId
where
NewsCategory.CategoryId in (Select CategoryId
from Category
where CategoryName = 'travel'
or CategoryName = 'Technology'
or CategoryName = 'Sport')
group by
n.NewsId, n.NewsTitle