34,838
社区成员




declare @t table(images2 varchar(10),images varchar(10),cph int,xm varchar(10),rq datetime,
flag varchar(10),kh varchar(10))
select (case when flag='进口机' then images2 end)images2,
(case when flag='出口机' then images end)images,cph
from @t
where datediff(day,rq,getdate())>=1
and images2 is not null and images is not null
/*
images2 images cph
---------- ---------- -----------
(所影响的行数为 0 行)
*/
select cph,rq,max(case when flag='进口机' then images2 end)images2,
max(case when flag='出口机' then images end)images
from jcjl2
where datediff(day,rq,getdate())>=tpbcts
and images2 is not null and images is not null group by cph,rq
select (case when flag='进口机' then images2 end)images2,
(case when flag='出口机' then images end)images,cph
from jcjl2 where datediff(day,rq,getdate())>=tpbcts
and images2 is not null and images is not null