我有一个SCCM表[dbo].[v_GS_OPERATING_SYSTEM] OS
,其中约560000行用于Microsoft Enterprise 7。
select *
from v_GS_OPERATING_SYSTEM
where caption0 like '%7%'
order by caption0
返回56642行,如果我写
select *
from v_GS_OPERATING_SYSTEM
where caption0 like '%Windows 7%'
order by caption0
我得到41462行。使用连接时会造成问题。
我用datesinfo创建了一个表,在其中输入了这样的数据
因此,当我加入连接时,它没有返回正确的数据;代替56000行,当我使用serverinfo作为连接时,它将返回41000行
查询
select
count(distinct OS.resourceid) as ModelCount,
convert(nvarchar(300), serverinfo),
OS.Caption0, dt.Servicepack,
dt.extendedsupportEnddate, dt.servicepacksupportenddate,
case
when DATEDIFF(month, getdate(), dt.servicepacksupportenddate) < 0
then 'black'
when DATEDIFF(month, getdate(), dt.servicepacksupportenddate) > 0
and DATEDIFF(month, getdate(), dt.servicepacksupportenddate) < 6
then 'red'
when DATEDIFF(month,getdate(),dt.servicepacksupportenddate) > 6
and DATEDIFF(month, getdate(), dt.servicepacksupportenddate) < 12
then 'orange'
when DATEDIFF(month, getdate(), dt.servicepacksupportenddate) > 12
then 'green'
else ''
End As PieColor
from
[dbo].[v_GS_OPERATING_SYSTEM] OS
left join
datesinfo dt on os.caption0 = dt.serverinfo
where
os.caption0 not like '%Server%'
and os.caption0 not like '%Windows 10%'
and (caption0 like N'%Windows 7%' or caption0 like N'%Windows 8%' or caption0 like N'%Windows Vista%')
group by
dt.Servicepack, serverinfo, dt.servicepacksupportenddate,
dt.extendedsupportenddate, OS.Caption0
所以我要加入字符而不是id,请您帮忙吗?