Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

IF/ELSE query for date results - response (1) by VBurmist

$
0
0

 

create table A (

dt date,

v varchar(5)

);

insert into A values ('2013-05-05','xxxx1');

insert into A values ('2013-05-07','xxxx2');

insert into A values ('2013-05-08','xxxx3');

 

create table B(

dt date

);

insert into B values ('2013-05-06');

insert into B values ('2013-05-07');

 

 

select B.dt,

             case when A.dt is not null then A.v else A_max.v end as v 

from B

join (select max(v) as v from A) as A_max ON 1=1 

left join A ON B.dt = A.dt

order by 1

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>