SQL case statement in Teradata -
i'm trying write simple if/else statement in teradata. far understand have use case. want write statement check if column not null , display something. else if null, display else.
every example found replaces single value hard coded string or int. i'm looking more along lines of uses statement make select:
select cars.vin_num, cars.driver_names case when cars.fuel not null select cars.destinations when cars.fuel null select cars.gas_stations end automobiles cars cars.vin_num in ('345353', '354632', '535231') order cars.vin_num
the end result should table displaying vin_num, driver_names, destinations or gas_stations based on case. possible or going wrong way?
if destinations
, gas_stations
columns in table automobiles
(aliased cars
) following should work:
select cars.vin_num, cars.driver_names, case when cars.fuel not null cars.destinations else cars.gas_stations end automobiles cars cars.vin_num in ('345353', '354632', '535231') order cars.vin_num;
Comments
Post a Comment