Quantcast
Channel: T-SQL Question
Viewing all articles
Browse latest Browse all 4

T-SQL Question

$
0
0
CREATE TABLE mytable(
   order_dt    DATE  NOT NULL  
  ,source_type VARCHAR(3) NOT NULL
  ,co2         INT 
);
INSERT INTO mytable(order_dt,source_type,co2) VALUES
 ('12-31-2018','abc',50)
,('12-31-2018','cde',30)
,('12-31-2018','xyz',52)
,('12-30-2018','abc',45)
,('12-30-2018','cde',NULL)
,('12-29-2018','xyz',NULL);


select source_type from mytable
 where co2 is not null and order_dt = '12-31-2018' 
intersect
select source_type from mytable
 where   co2 is NULL and (  order_dt = '12-30-2018' or   order_dt = '12-29-2018')

 
 drop table mytable
 


Viewing all articles
Browse latest Browse all 4

Trending Articles