I've got a table(concepttable) w开发者_如何学Chich has stored emotions in conceptname column such as happy sad etc. Users can add more emotions in it via asp web form. In the same dataset there is another table called (blog) that has a string of multiple blog entries with there entry dates.
How would i go around by using a service report to use a droplist that displays the stored emotions in (conceptname) and then shows how many times that selected emotion such as sad has appeared in all blogcontent strings in the blog table?
Any help is appreciated, I've been trying blindly using joins and full text searches but am not certain what way to go around to achieve this. Ive attached an image showing the data sources.
The output i want to achieve is a chart similar to this:
Sorry if this is vague, add a comment if your not sure what i mean. Thanks for any help!
Here is the SQL you need:
select conceptName,COUNT(distinct blogId) as Tot
from conceptTable ct
join blogs on content like '%'+ct.conceptName+'%'
group by conceptName
To get the first date a concept appears
select conceptName,min(inputDate) as FirstTime,COUNT(distinct blogId) as Tot
from conceptTable ct
join blogs on content like '%'+ct.conceptName+'%'
group by conceptName
To get the most recent date a concept appears
select conceptName,max(inputDate) as MostRecent,COUNT(distinct blogId) as Tot
from conceptTable ct
join blogs on content like '%'+ct.conceptName+'%'
group by conceptName
To get all dates
select conceptName,inputDate,COUNT(distinct blogId) as Tot
from conceptTable ct
join blogs on content like '%'+ct.conceptName+'%'
group by conceptName,inputDate
精彩评论