Search code examples
sqlsql-serverapache-drill

How to a check column exits in a table in SQL drill query


SELECT t1.customerInformation.customerid AS CustomerId
FROM EndUserNotificationHistoryEvent t1
WHERE t1.operationType <> 'DELETE';

In this above query where condition should be executed only when operationType column is present in the table. If operationType column is not present where condition is no needed.


Solution

  • Try This:

    SELECT t1.customerInformation.customerid AS CustomerId
    FROM EndUserNotificationHistoryEvent t1
    WHERE (t1.operationType <> 'DELETE' OR t1.operationType IS NULL)