Solved

Get Related topics based on WordWeight

Posted on 2014-01-29
8
152 Views
Last Modified: 2014-01-31
Dear all,
I have tale NewsSYSNewsTags (NewsSYSNewsTagsID PK, NewsID (fk), NewsSYSTagsID (fk)WordWeight

for given NewsID how can get the most related newsID

thanks
0
Comment
Question by:ethar1
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39818494
>for given NewsID how can get the most related newsID
Define 'most related', preferable with some mockup 'before and after' data.  

Where I'm from you could be cousins multiple ways.
0
 

Author Comment

by:ethar1
ID: 39818499
based on WordWeight as mentioned
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39818619
what is meant my word weight is it another column in a different table or word weight is some kind of functional requirement.

if it is the later, can you please take an example and explain to us.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:ethar1
ID: 39818936
Table :
 NewsSYSNewsTags (NewsSYSNewsTagsID PK, NewsID (fk), NewsSYSTagsID (fk), WordWeight)

yes its a column in same table  its a float field.
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39818956
ok, can you please give us some examples with the data for the table and also the output that you are expecting..

while providing this data, please let us know how this output has come up...
The data can be a dummy data nothing in your real tables.
0
 
LVL 12

Expert Comment

by:Harish Varghese
ID: 39819956
Are you looking for NewsIDs with NewsTags having same WordWeight as given NewsID?
If there are multiple NewsTags in the given NewsID, what should be the criteria to pick the other relevant NewsID?
0
 

Author Comment

by:ethar1
ID: 39819983
@Harish Varghese, yes this is exactly what I am looking for , sure there are multiple NewsTags in the given NewsID.
The criteria (fmho):
for each NewsSYSTagsID of given NewsID
insert in releated table
select  NewsID  where WordWeight = +- 5% of (WordWeight  of GivenNewsID) and NewsID <> given NewsID
order by WordWeight  Desc


thanks
0
 
LVL 12

Accepted Solution

by:
Harish Varghese earned 500 total points
ID: 39819993
Hello,

Here is a query to identify the related news. I am selecting the news tag id and the word weights for the given news id and related news id. You may pick only the columns you want finally.
Insert into @RelatedNewsIDs (MainNewsID, NewsSYSTagsID, MainWordWeight, RelatedNewsID, RelatedWordWeight)
Select Distinct Main.NewsID, Main.NewsSYSTagsID, Main.WordWeight, Related.NewsID, Related.WordWeight
From NewsSYSNewsTags Main, NewsSYSNewsTags Related
Where Related.NewsID <> Main.NewsID
And Related.NewsSYSTagsID  = Main.NewsSYSTagsID 
And Related.WordWeight >= Main.WordWeight - Main.WordWeight * .05 
And Related.WordWeight <= Main.WordWeight + Main.WordWeight * .05 
And Main.NewsId = 1001 --Your news ID to search

Open in new window

-Harish
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question