Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a Case Statement in U-SQL

Tags:

u-sql

Wondering if anyone has suggestions on implementing a case or IF statement with U-SQL. For example, how do i convert this:

SELECT
    FirstName, LastName,
    Salary, DOB,
    CASE Gender
        WHEN 'M' THEN 'Male'
        WHEN 'F' THEN 'Female'
    END
FROM Employees;
like image 409
enufeffizy Avatar asked Dec 15 '22 06:12

enufeffizy


1 Answers

You can use an inline C# expression for simple things like so (did not test it yet though)

SELECT
    FirstName, LastName,
    Salary, DOB,
    Gender == "Male" ? "M" : "F"
FROM Employees

If it is more complex consider writing a user defined operator in C#.
Have a look at the MSDN tutorial here

like image 70
DAXaholic Avatar answered Dec 16 '22 19:12

DAXaholic