I have 4 column id like to return for each transmitter, ALM_LL, ALM_L, ALM_H and ALM_HH. Is there a way to summarize these 4 columns in the query so it returns a single value of these 4 columns being ANDED?
What database are you using?
Depending on what you’re trying to do it might make sense to do one of the following:
- AND the values in your SQL query
- Have FactorySQL AND the values in an “Action Item”
- AND the values in an expression in FactoryPMI.
Please describe where you’re using the data.
Using a MySQL 5.0 database. The data is in 4 columns, as previously stated. I want to take the 4 alarm values, and make the fill on the box around my pv value change green if there are no alarms, or red is there is an alarm.
MySQL lets you use “&&” or “AND” for and, and “||” or “OR” for the or operatior. See this page for details on MySQL logic operators:
dev.mysql.com/doc/refman/5.0/en/ … ators.html
It sounds to me like you really want an OR, not an AND, if you want to turn a color red when any alarm goes on.
In any case, that query would look like this:
SELECT ALM_LL OR ALM_L OR ALM_H OR ALM_HH AS MyAlarm FROM MyTable
If you really did want ANDs, you just replace the ORs with ANDs.
Bind an integer property to that query, and then bind your box’s background color to the integer to set up your color mapping.
Hope this helps,
Of course, if you have multiple rows there will be multiple rows returned. If you just want the overall result for all rows, you could shift the logic to the where clause:
SELECT count(*) as RowsInAlarm FROM MyTable WHERE ALM_LL OR ALM_L OR ALM_H OR ALM_HH
That will give you a single number: the number of rows “in alarm”. To get it down to an overall boolean (“is there any alarm at all”), you could just do this:
SELECT count(*)>0 as RowsInAlarm FROM MyTable WHERE ALM_LL OR ALM_L OR ALM_H OR ALM_HH
That extra “>0” turns it into a boolean operation that will return true or false.
Hope this helps,[/code]
Yeah Carl, you are right. I need ANDs however as my alarming is written in negative logic
Ah, I should have known. Let us know if you need any more assistance.