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

problem of querying the data from the SQLFile using Openstudio measure

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

Dr. Fan gravatar image

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

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
1

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

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

Stats

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

Seen: 168 times

Last updated: Sep 29 '20