none
SELECT DISTINCT row - USQL

    Question

  • Hi all,

    Is there a way to do a SELECT DISTINCT(column_name) in USQL like you would do in SQL?

    Example:

    @input EXTRACT column1 string, column2 string ....

    @noDupInput SELECT column1, column2 .... (Let's say I want to do a distinct on column 1 value or just the entire row)

    I pretty much just want to filter out duplicates and I know USQL uses C# language a lot but couldn't find much about distinct feature for USQL specific.

    Thanks


    Choiboy

    Monday, March 18, 2019 7:51 AM

All replies

  • Hello Choiboy96.  Thank you for your question.

    There is a DISTINCT keyword in U-SQL.  Here are links to the appropriate documentation.

    https://docs.microsoft.com/en-us/u-sql/statements-and-expressions/select/select-clause
    https://docs.microsoft.com/en-us/u-sql/statements-and-expressions/select/select-clause#dist

    In your example it would be:
    @noDupInput = SELECT DISTINCT column1, column2 .... FROM @input;

    Does this help you?

    Monday, March 18, 2019 8:42 PM
    Moderator
  •  Worked fine, thanks! Couldn't find it in the documentation when I was scanning through :(

    Choiboy

    Monday, March 18, 2019 11:01 PM
  • Glad I could help!  Could you please "Mark as answer", so I may close this case?  Thank you!
    Tuesday, March 19, 2019 6:15 PM
    Moderator