带有时间范围的标签值

时间:2018-10-21 01:30:14

标签: influxdb

有什么方法可以检索时间范围内的TAG值?

SHOW TAG VALUES FROM test WITH KEY = "name" WHERE time > NOW() - 12h

上面的查询甚至返回了过去12天中没有插入任何记录的3天标签值。

1 个答案:

答案 0 :(得分:0)

您无法使用Sub CompareCopyFilter() Dim CopyFromWorkbook As Workbook Set CopyFromWorkbook = Workbooks("Master File.xlsm") 'Name the Workbook that should be copied from Dim CopyToWorkbook As Workbook Set CopyToWorkbook = Workbooks("Master File.xlsm") 'Name the Workbook that should be copied to Dim CopyFromSheet As Worksheet Set CopyFromSheet = CopyFromWorkbook.Worksheets("UnSlotted") 'Name the Worksheet that should be copied from Dim CopyToSheet As Worksheet Set CopyToSheet = CopyToWorkbook.Worksheets("Master File") 'Name the Worksheet that should be copied to Dim lrow As Long Dim lrowCompare As Long Dim lrowPasteCopyTo As Long Dim Val As String Dim ValCompare As String Dim j As Long Dim Test As String Dim Test2 As String Dim cl As Range Dim rng As Range Dim CurrentRow As Long lrow = CopyFromSheet.Cells(Rows.Count, "A").End(xlUp).Row 'Find last row in sheet that should be copied from lrowCompare = CopyToSheet.Cells(Rows.Count, "A").End(xlUp).Row 'Find last row in sheet that should be copied from CopyFromSheet.Activate 'Activate From Sheet Set rng = CopyFromSheet.Range(Cells(2, 1), Cells(lrow, 1)) 'Set Range to apply filter on CopyFromSheet.Range("A1:M1").AutoFilter Field:=13, Criteria1:="OK", VisibleDropDown:=True 'Filter Column M, based on criteria "OK" in the sheet you want to copy from For Each cl In rng.SpecialCells(xlCellTypeVisible) 'Loop throug all visible cells in range CurrentRow = cl.Row 'Row number for current cell in filtered filter Val = CopyFromSheet.Cells(CurrentRow, "A").Value 'Get the value from the cell you want to copy from For j = 2 To lrowCompare 'Loop through the value in the sheet you want to copy to ValCompare = CopyToSheet.Cells(j, "A").Value 'Get the value from the cell you want to copy to If Val = ValCompare Then 'Compare the values between the two workbooks, if the match (exact match) then CopyFromSheet.Activate CopyFromSheet.Range(Cells(CurrentRow, "A"), Cells(CurrentRow, "AA")).Copy 'Copy row from Column A to Column AA CopyToSheet.Activate 'Activate workbook to paste into CopyToSheet.Range(Cells(j, "A"), Cells(j, "AA")).PasteSpecial xlPasteValues 'Paste values into range. End If Next j Next cl Application.CutCopyMode = False 'Deselect any copy selection End Sub 查询标签。我认为接受where的{​​{1}}是InfluxQL解析器的一个小错误。原因是标签存储为索引值,并且没有快速的方法来回答您的请求(并且where被认为是快速的)。

如果您真的想要,可以尝试这种方法(因为它需要通过数据库进行研磨,所以很慢):

show tags

要使其正常工作,您需要至少提供一个字段名称(以后可能会忽略)。这是Influx的局限性,您不能仅对标签进行查询。