以下に1つの表を示します。
次のクエリでは、外側のクエリがサブクエリとlike
の列の比較で結合されます。tag
SELECT top 6 *
FROM [piarchive].[picomp2]
WHERE tag Like
(
Select distinct left(tag,19) + '%'
from (SELECT *
FROM [piarchive].[picomp2]
WHERE tag like '%CPU_Active' and time between '2014/10/02 15:13:08'and'2014/10/02 15:18:37'
and value=-524289 order by time desc) as t1
)
and tag not like '%CPU_Active' and tag not like '%Program%' and time between '2014/10/02
15:13:08'and'2014/10/02 15:18:37' order by time desc
ただし、このサブクエリは複数の行を返すため、次のエラーが発生します。
エラー : 「式として使用する場合、サブクエリは最大で 1 行を返すことができます。」