I have one column. show measurements. And I want to find out the min and the max difference. Then if the difference more than 100 I like to change one another column on different table boolean troue to false. If less than 100 no change.
The "t1" column on the "Table_1_Furnace_1" table column. Same database have the another table, "StatusTable" and one boolean column "Status_Column".
If the difference more than 100 then need to change the status to true.
My half query is:
select max("t1") - min("t1") as difference from "Table_1_Furnace_1"; This is found the difference between min and max. But how can I add how it the difference more than 100 change the boolean column to true.
Idea but not work:
select max("t1") - min("t1") as difference from "Table_1_Furnace_1" update "statusTable" set "Status_Column" = true where difference > 100; Let me try to explain better.
Measurements table:
| ID | measurements |
|---|---|
| 1 | 200 |
| 2 | 200 |
| 3 | 210 |
| 4 | 100 |
| 5 | 500 |
| 6 | 600 |
| 7 | 800 |
| 8 | 550 |
to 700 ID and measurements. all Integer value.
Status table: Status column boolean. Default False.
I need to choose 2 ID. and under the ID same row have one measurement. example: Choose ID 1 and ID 8. That is 8 ID and same row 5 different measurement.
| ID | measurements |
|---|---|
| 1 | 200 |
| 2 | 200 |
| 3 | 210 |
| 4 | 100 |
| 5 | 500 |
| 6 | 600 |
| 7 | 800 |
| 8 | 550 |
We need to find the minimum ( ID 4 ) and need to find the maximum ( ID 7 ) If the minimum the ID 4 that case we not care after the ID-s before ( 1-2-3 ). After need to find out the difference between min and max. If the minimum have before ( ID 4 ) and the maximum after ( ID 7 ) and the difference more than 100 that case need to change the Status boolean to true. If less than, or the maximum have before and then the minimum ( the temperature go lower not higher ) that case also not need to change true. This is can be one single query or automatized if possible.
"statusTable". How is"statusTable"related to"Table_1_Furnace_1"?