1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
go
create table tmp( id int,strX varchar(10), dtY smalldatetime )
Go
insert tmp values(1,'test','1900-01-01')
Go
insert tmp values(2,'test',null)
go
insert tmp values(3,null,'1900-02-02')
go
--J'ai toutes les données
select * from tmp
go
--me manque les données avec les valeurs null
select *
from tmp as t1,
tmp as t2
where t1.id = t2.id
and t1.strX = t2.strX
and t1.dtY = t2.dtY
--ou avec join
----me manque les données avec les valeurs null
select *
from tmp as t1 join
tmp as t2 on
t1.id = t2.id
and t1.strX = t2.strX
and t1.dtY = t2.dtY
Gp
--C'est une solution mais ce n'est pas très beau
select *
from tmp as t1,
tmp as t2
where t1.id = t2.id
and (case when t1.strX is null then 'qsdf123' else t1.strX end ) = (case when t2.strX is null then 'qsdf123' else t2.strX end )
and (case when t1.dtY is null then '1900-01-01' else t1.dtY end )= (case when t2.dtY is null then '1900-01-01' else t2.dtY end ) |
Partager