我在Stream Analytics中使用了两个子查询,因此我可以运行两个AzureML函数。
WITH subquery as (
SELECT
id as id,
username as username,
try_cast(startTime as datetime) as startTime,
try_cast(endTime as datetime) as endTime,
AC as AC, FM as FM, UC as UC,
DL as DL, DS as DS, DP as DP,
LB as LB, ASTV as ASTV, MSTV as MSTV,
ALTV as ALTV, MLTV as MLTV, Width as Width,
Min as Min, Max as Max, Nmax as Nmax,
Nzeros as Nzeros, Mode as Mode, Mean as Mean,
Median as Median, Variance as Variance, Tendency as Tendency,
rms,fmed,fpeak,sample_entropy,
EventProcessedUtcTime as EventProcessedUtcTime,
Distress(AC,FM,UC,DL,DS,DP,1,LB,ASTV,MSTV,ALTV,MLTV,
Width,Min,Max,Nmax,Nzeros,Mode,Mean,Median,Variance,
Tendency,1,1,1,1,1,1,1,1,1,1,1,1) as resultFHR
FROM
iot
),
subquery2 as (
SELECT
id as id,
try_cast(startTime as datetime) as startTime,
try_cast(endTime as datetime) as endTime,
AC as AC, FM as FM, UC as UC,
DL as DL, DS as DS, DP as DP,
LB as LB, ASTV as ASTV, MSTV as MSTV,
ALTV as ALTV, MLTV as MLTV, Width as Width,
Min as Min, Max as Max, Nmax as Nmax,
Nzeros as Nzeros, Mode as Mode, Mean as Mean,
Median as Median, Variance as Variance, Tendency as Tendency,
rms,fmed,fpeak,sample_entropy,
EventProcessedUtcTime as EventProcessedUtcTime,
Labour("",1,1,1,"",rms,fmed,fpeak,sample_entropy,"","") as resultUC
FROM
iot
)
SELECT
id as id,
username as username,
startTime as startTime,
endTime as endTime,
AC as AC, FM as FM, UC as UC,
DL as DL, DS as DS, DP as DP,
LB as LB, ASTV as ASTV, MSTV as MSTV,
ALTV as ALTV, MLTV as MLTV, Width as Width,
Min as Min, Max as Max, Nmax as Nmax,
Nzeros as Nzeros, Mode as Mode, Mean as Mean,
Median as Median, Variance as Variance, Tendency as Tendency,
EventProcessedUtcTime as EventProcessedUtcTime,
resultFHR.[classes] as distress,
resultFHR.[probabilities] as distressProbability,
resultUC.[classes] as labour,
resultUC.[probabilities] as labourProbability
INTO
sql
FROM
subquery INNER JOIN subquery2 ON subquery.id = subquery2.id
AND DATEDIFF(second, subquery, subquery2) BETWEEN 0 AND 20
SELECT
*
INTO
c2d
FROM
subquery INNER JOIN subquery2 ON subquery.id = subquery2.id
AND DATEDIFF(second, subquery, subquery2) BETWEEN 0 AND 20
我尝试使用Inner Join来连接两个子查询,但它适用于第二个查询,不适用于第一个查询。当我在第一个查询中使用内部联接时,它将显示错误。
列名无效:' id'。具有此类名称的列不存在。
任何解决方案?
答案 0 :(得分:2)
由于您加入了两个来源subquery
和subquery2
,因此您需要像使用ON子句(subquery.id = subquery2.id
)那样使用源名称限定列。
只有当您拥有单一来源时,才允许使用非限定名称,例如subquery
步骤中。
更改列引用以完全限定它们,如下所示:
SELECT
subquery.id as id,
subquery.username as username,
subquery.startTime as startTime,
subquery.endTime as endTime,
...