mercredi 31 août 2016

CASE Statement with conditions

Iam trying to write two CASE Statements. The First CASE statement just sees if a field is empty, if empty it shows the value of another field. The CASE statement is below:

CASE 
When commercial_logi_freight.cust_shipmentdate_awb Is Null Or 
commercial_logi_freight.cust_shipmentdate_awb = '' Then
 commercial_logi_freight.comp_shipdate_awb
    Else commercial_logi_freight.cust_shipmentdate_awb End AS shipment_date

Now i need one more CASE statement which should check if shipment_date which is the result of the above CASE statement is NULL or not, if NULL or EMPTY it should show 'Pending" or else 'Completed'. Something like this. But its wrong.

Case When shipment_date Is Null Or shipment_date = '' Then 'Pending' Else 'Completed' End AS 
shipment_status

Aucun commentaire:

Enregistrer un commentaire