How to select top 10 records from 2 distinct groups

  • Try

    WHERE DXCD1 IN ('7140') OR DXCD1 IS NULL

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • This is slightly wrong

    WHERE DXCD1 IN (IS NULL, '7140')

    Try

    WHERE DXCD1 IS NULL OR DXCD1 = '7140'

  • IBeDatMan (3/3/2016)

    Thanks for taking a stab at this. I modified your code for my purposes but I get an error: Syntax error, expected something like a name or a Unicode delimited identifier between the word 'num' and '='. Here is my code:

    num = ROW_NUMBER() OVER (PARTITION BY DXCD1 ORDER BY DXCD1())

    In addition to what's already been pointed out, you need to remove the brackets "()" after DXCD1.

    It appears that you are trying to order by the same value that you are partitioning by. The reason for the NEWID(), was simply to take a *random* sampling of the records for the given partition.

Viewing 3 posts - 16 through 17 (of 17 total)

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