First time here? Check our help page!
2

problem of querying the data from the SQLFile using Openstudio measure

We can get values from sqlfile by the command: "sqlFile.execAndReturnFirstString(query)". But it only calls values from the table "tabulardatawithstrings" in sqlfile. If I want to select values from other tables(like "ReportVariableDataDictionary"), what kind of command should I use?

Dr. Fan's avatar
430
Dr. Fan
asked 2020-09-29 07:09:33 -0500
shorowit's avatar
11.8k
shorowit
updated 2020-09-29 15:13:02 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

The sqlFile.execAndReturn... methods query values from whatever Sql table you ask it to. It is not hard-coded to query the TabularDataWithStrings table.

For example, here is a query from one of my own reporting measures that queries the ReportMeterData table:

query = "SELECT SUM(VariableValue) FROM ReportMeterData WHERE ReportMeterDataDictionaryIndex IN (SELECT ReportMeterDataDictionaryIndex FROM ReportMeterDataDictionary WHERE VariableName='Electricity:Facility' AND ReportingFrequency='Run Period' AND VariableUnits='J')"

value = sqlFile.execAndReturnFirstDouble(query).get
puts value
shorowit's avatar
11.8k
shorowit
answered 2020-09-29 15:20:06 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments