Top 10 based on multiple criteria

  • Without CREATE TABLE statements for the tables and INSERT statements for sample data, and with no posted exact required output, you are leaving a lot to the imagination.

    However, if I understand the requirement correctly, I think you'll need something like:

    SELECT Name, the, columns

    FROM dbo.DelimitedSplit8k(@TITLES, ',') AS s

    CROSS APPLY

    (SELECT TOP(10) More, columns, to, name

    FROM dbo.Ref AS v

    WHERE v.Title LIKE '%' + s.Item + '%'

    ORDER BY Whatever);


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Hugo, my apologies as it was an SSRS question I didn't post more but you are right best to put everything on here.

    Actually what you gave me worked perfectly, so really appreciated. I have used it in Dev so far, so will look at prod next.

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

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