Aracılığıyla paylaş


NOT (U-SQL)

Summary

U-SQL’s logical NOT operator performs a negation of the Boolean expression and returns false if the expression evaluates to true and true if it evaluates to false. It is equivalent to the C# ! operator.

When more than one logical operator is used in an expression, NOT operators bind stronger than AND and OR. Parentheses can be used to change the binding precedence.

Syntax

NOT_Expression :=                                                                                        
     'NOT' Boolean_Expression.

Remarks

  • Boolean_Expression
    The Boolean expression to be negated that returns a not-null value of type bool.

Return Type

bool

Examples

  • The examples can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
  • The scripts can be executed locally. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.

Return all records where EmpName does not start with E.

@data  = 
    SELECT * FROM 
        (VALUES  
        (1, "Noah",   100, (int?)10000, new DateTime(2012,05,31)),
        (2, "Sophia", 100, (int?)15000, new DateTime(2012,03,19)),
        (3, "Liam",   100, (int?)30000, new DateTime(2014,09,14)),
        (6, "Emma",   200, (int?)8000,  new DateTime(2014,03,08)),
        (7, "Jacob",  200, (int?)8000,  new DateTime(2014,09,02)),
        (8, "Olivia", 200, (int?)8000,  new DateTime(2013,12,11)),
        (9, "Mason",  300, (int?)50000, new DateTime(2016,01,01)),
        (10, "Ava",   400, (int?)15000, new DateTime(2014,09,14)),
        (11, "Ethan", 400, (int?)null,  new DateTime(2015,08,22))
        ) AS T(EmpID, EmpName, DeptID, Salary, StartDate);

@result =
    SELECT * FROM @data
    WHERE NOT EmpName.StartsWith("E");

OUTPUT @result TO "ReferenceGuide/Operators/Logical/Not1.txt" USING Outputters.Csv();

// alternative
@result =
    SELECT * FROM @data
    WHERE  !EmpName.StartsWith("E");

OUTPUT @result TO "ReferenceGuide/Operators/Logical/Not2.txt" USING Outputters.Csv();

// alternative
@result =
    SELECT * FROM @data
    WHERE  EmpName NOT LIKE "E%";

OUTPUT @result TO "ReferenceGuide/Operators/Logical/Not3.txt" USING Outputters.Csv();

See Also