Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

problem of querying the data from the SQLFile using Openstudio measure

asked 2020-09-29 07:09:33 -0600

Dr. Fan's avatar

updated 2020-09-29 15:13:02 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-09-29 15:20:06 -0600

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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer


Question Tools

1 follower


Asked: 2020-09-29 07:09:33 -0600

Seen: 194 times

Last updated: Sep 29 '20