sql - Signal value classification by limits from database -
Looking at some signals, I need to know the position of the machine with the minimum and maximum limit. I am planning to create a table with data)
| StateID | Signalid | Min. Max | | --------- | ---------- | ----- | ----- | | 1 | 1 | 1 | 2 | | 1 | 3 | 2 | 3 | | 2 | 2 | 0 | 4 | | 3 | 2 | 5 | 9 | In this way, I can obtain potential states through those lines (in the sense that the value of the signal ID is between the minimum and the maximum). The valid states gap should be in the correct position for all signs (table handling has been completed in that manner). But - for some states there is probably no relation to a given signal - I think that the states should start again - do somehow feel incompetence, or? Some examples from the table above (where full meaning is, SignalValue is between minimum and maximum):
- (1,2,3) - & gt; 1 (line 1 and 2 complete) or - & gt; 2 (line 3 complete)
- (2,9,2) - & gt; 1 (line 1 and 2 complete) or - & gt; 3 (line 4 full)
- (3,1,3) - & gt; 2 (line 3 complete)
- (3,8,2) - & gt; I have a few questions starting with <3> (line 4 complete only)
- Do I have to adjust the table structure (or logic) Can I change something?
- How can I handle the situation which is not dependent on the signal without adding a line with minimum = -infinity and max = infinity?
- The number of states and signals is dynamic - how to efficiently query related queries? Is intersection (a dynamic calculation of results) can be done in SQL?
Thanks for any thoughts and help.
OK, I am not going to answer the question I'm asking for, had asked. So please make it more clear and if I did not find what you are trying to do.
You are collecting two different facts, but you have only given an example for one.
Tables valid_states (state_nbr integer not tap, signal_nbr integer, signal_min integer, signal_max integer, make primary key: i allow you to record one) and b) states observed, ie Assuming (state_nbr, signal_nbr)); Create tab_ signal (signal_NBR integer primary key, signal_value integer null); You can choose from both for "Considered legitimate state (s)" again:
SELECT s.state_nbr, o.signal_nbr From the valid_state or (s.signal_max is the left_spaced_signals as s.signal_nbr = o.signal_nbr on o.s.signal_min o.signal_value and s.signal_max or (= s.signal_max s.signal_min zero and o.signal_value & Lt) Join zero and o.signal_value & gt; = s.signal_min) or (s.signal_min IS Null and s.signal_max IS is tap); Well, maybe there are ways to write this query more effectively, but you get this idea.
Comments
Post a Comment