Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have the following select statement,
SQL
SELECT Content,
CustomField,
Disabled,
ObjectId as id
FROM itsm.ObjectCustomFieldValues
WHERE CustomField = 4 OR CustomField = 5 OR CustomField = 7 OR CustomField = 8
AND Disabled = 0;
This statement works, but I need to take CustomField where it equals 4 or 7 and make it into a field called Category, and where CustomField equals 5 or 8 into a field called SubCategory.
Can this be done?
Sure, something like this:
T1:
load Content, CustomField,
if(CustomField = 4 or Customfield = 7, CustomField) as Category,
if(CustomField = 5 or Customfield = 8, CustomField) as SubCategory,
Disabled,
id;
SELECT Content,
CustomField,
Disabled,
ObjectId as id
FROM itsm.ObjectCustomFieldValues
WHERE CustomField = 4 OR CustomField = 5 OR CustomField = 7 OR CustomField = 8
AND Disabled = 0;
Sure, something like this:
T1:
load Content, CustomField,
if(CustomField = 4 or Customfield = 7, CustomField) as Category,
if(CustomField = 5 or Customfield = 8, CustomField) as SubCategory,
Disabled,
id;
SELECT Content,
CustomField,
Disabled,
ObjectId as id
FROM itsm.ObjectCustomFieldValues
WHERE CustomField = 4 OR CustomField = 5 OR CustomField = 7 OR CustomField = 8
AND Disabled = 0;
Thanks. That worked!