cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Query to find the multiple values for same KW

Anil_Patel1
Champ in-the-making
Champ in-the-making

Hello,

How can I get the report or query to see all the possible / exiting values for keyword if that key word has multiple values?

I can execute the search like show me all docs created in last two days (assuming that some of the docs have multiple values (F6) for the KW, when I extract the KW through List report off the search result, I can see only first value of that KW, I need to know all the values for that KW

Your help is greatly appreciated

Thanks

Anil

 

 

9 REPLIES 9

Greg_Ledford
Star Contributor
Star Contributor

Try this....   SELECT DISTINCT(<keyword name>) FROM <table name> ORDER BY <keyword name>. 

Anil_Patel1
Champ in-the-making
Champ in-the-making

Thanks Greg,

I guess I didn't explain correctly, here is the scenario:

Let’s say Document Type = ABC, has a one KW called Reviewers: For Document 1, doc type will be ABC, but Reviewers values for that document may have multiple entries like Document 1 will get reviewed by person X, Person Y, Person Z. The Values get stored under Reviewers KW as three separate entries when you look the Document KW.

I need to get the list all three person's name in my list for Document 1

Document1        person X

                          Person Y

                          Person Z

Document321    person X

                         Person Y

                        Person Z

Does it make any sense?

Thanks for looking into my Q

Anil

 

John_Anderson4
Star Collaborator
Star Collaborator

Assuming this is a standalone keyword (not part of a keyword group) this query would return a list of the doc handles that have more than one value for a certain keyword (in this case keyword #179). I'm also limiting it to doc type #140, but you can remove that restriction if you want to look at ALL documents.

SELECT kw.itemnum, Count(kw.itemnum) AS 'numkeys'
FROM hsi.itemdata it with(nolock)
inner join hsi.keyitem179 kw with(nolock) on kw.itemnum=it.itemnum
WHERE it.status = 0 and it.itemtypenum=140
GROUP BY kw.itemnum
HAVING (Count(kw.itemnum)>1)

Greg_Ledford
Star Contributor
Star Contributor

Ah..yes, that makes sense. In that situation, John's suggestion would be the way to go.