私はこのようなSQLを持っています:
SELECT
Mid(Note,
InStr(Note, "device.")-
(
InStr(Note, "device.")-
InStr(Note, "pressure and")
)
+13,
(InStr(Note, "device.") - InStr(Note, "pressure and")) - 14
)
AS [Device],
Count([Device]),
Date_Field & " " & Time_Field AS [DateTime],
EnteredBy
FROM MyLog
WHERE Note LIKE "*removed and*"
GROUP BY [Device]
ORDER BY Date_Field DESC
;
GROUP BY
そのカスタムフィールド[Device]
に、各デバイスがいくつあるかを数えたいと思います。ただし、上記のコードでは、「...AS[デバイス]」セクションに「...指定された式を...集計関数の一部として含めないでください」というエラーが表示されます。
どうすればこれを達成できますか?
現在、データは次のようになっています。
Record1 12/05/12 03:02:12 User2
Record1 12/02/12 01:02:12 User1
Record1 12/01/12 02:02:12 User2
Record2 12/06/12 03:02:12 User2
Record2 12/07/12 03:02:12 User3
しかし、私はそれを次のように見せたいと思います:
Record1 3
Record2 2
これは機能する古いSQLです(集約されません):
SELECT Mid(Note,
InStr(Note, "device.")-
(
InStr(Note, "device.")-
InStr(Note, "pressure and")
)
+13,
(InStr(Note, "device.") - InStr(Note, "pressure and")) - 14
) AS Device, Date_Field & " " & Time_Field AS [DateTime], EnteredBy
FROM MyLog
WHERE Note LIKE "*removed and*"
ORDER BY Date_Field DESC;