Grouping the words which has maximum count

  • Hi All,

    I have to highest two word in the columns. It should have the maximum two words combination.  I have attached the excel for reference.

    Attachments:
    You must be logged in to view attached files.
  • As stated in the other thread, download and install the following function in your DB

    CREATE_FUNCTION_dbo_DelimitedSplit8K_LEAD.sql

    Then use it as follows

    WITH cteTwoWords AS (
    SELECT TwoWords = ss.Item + ' ' + LEAD(ss.Item) OVER (PARTITION BY td.[title] ORDER BY ss.ItemNumber)
    FROM [title_one_space] AS td
    CROSS APPLY dbo.DelimitedSplit8K_LEAD(td.[title], ' ') AS ss
    )
    SELECT TwoWord_group = cte.TwoWords
    , TwoWord_count = COUNT(*)
    FROM cteTwoWords AS cte
    WHERE TwoWords IS NOT NULL
    GROUP BY TwoWords
    ORDER BY COUNT(*) DESC;

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply