首先,我一直在寻找答案,我也是SQL编码的新手,所以请耐心等待。
我正在尝试使用自定义报告发现SCCM 2012r2中客户端计算机的当前运行状况,请参阅以下代码:
SELECT v_r_system.name0 AS 'Computer Name',
v_gs_antimalwarehealthstatus.lastquickscanage AS 'Days since last quick scan',
v_gs_antimalwarehealthstatus.lastfullscanage AS 'Days Since Last Full Scan',
v_gs_antimalwareinfectionstatus.computerstatus AS 'Current Status',
v_gs_antimalwareinfectionstatus.lastcleaneddectiontime AS 'Last Cleaned'
FROM v_gs_antimalwarehealthstatus
INNER JOIN v_gs_antimalwarehealthstatus
INNER JOIN v_r_system
ON v_gs_antimalwarehealthstatus.resourceid = v_r_system.resourceid
INNER JOIN v_gs_antimalwareinfectionstatus;
当我在Report Builder 3.0中尝试时,我不断收到以下错误:
我似乎无法找到问题,这让我发疯了......
无论如何,你能做的任何事情都指向我正确的方向会很棒。
干杯
P上。
答案 0 :(得分:0)
在whith列上你是否加入了最后一个表v_gs_antimalwareinfectionstatus? 只需在ON-Clause中添加条件,它就可以正常工作
答案 1 :(得分:0)
我认为您的查询中有两个问题。第一:
FROM v_gs_antimalwarehealthstatus
INNER JOIN v_gs_antimalwarehealthstatus
为什么内部加入它自我?我认为这是不必要的,应该简单:
FROM v_gs_antimalwarehealthstatus
第二个是在最后一次加入中缺少ON
条件:
INNER JOIN v_gs_antimalwareinfectionstatus ON ... ....;
所以FROM .. JOIN
部分必须如下:
FROM v_gs_antimalwarehealthstatus
INNER JOIN v_r_system
ON v_gs_antimalwarehealthstatus.resourceid = v_r_system.resourceid
INNER JOIN v_gs_antimalwareinfectionstatus
ON v_gs_antimalwareinfectionstatus.<column> = <otherTable>.<column>
答案 2 :(得分:0)
您刚刚错过了语句中的ON Clause
,也可以使用table alias
,因为它使查询看起来干净。
SELECT v_r_system.name0 AS 'Computer Name',
v_gs_antimalwarehealthstatus.lastquickscanage AS 'Days since last quick scan',
v_gs_antimalwarehealthstatus.lastfullscanage AS 'Days Since Last Full Scan',
v_gs_antimalwareinfectionstatus.computerstatus AS 'Current Status',
v_gs_antimalwareinfectionstatus.lastcleaneddectiontime AS 'Last Cleaned'
FROM v_gs_antimalwarehealthstatus AWT
INNER JOIN v_r_system VRS
ON AWT.resourceid = VRS.resourceid
INNER JOIN v_gs_antimalwareinfectionstatus AWI
ON [Place the Matching columns here];