Extraction of overridden values

Hello

I have the following three tables

ShiftRule

-----------------------------------------------

EMPID MAJ

-----------------------------------------------

1                     1

2                     1

3                     3

4                     1

5                     2

-----------------------------------------------

SHIFTSCHEDULE

---------------------------

EMPID MAJ

--------------------------

1                4

2                4

5                1

-------------------------

SHIFTCHANGE

-----------------

EMPID MAJ

-------------------

1                3

--------------------

Maj rule shift default store for all employees.

If an employee is in a shiftschedule, his shift will be be substituted by Ceres in shiftschedule.

and if his shift came in at shift change, rule of shift and input lag will be overloaded with shiftchange values...

That is to say average to get the shift real shiftchange entered should be checked first. for the employee id for which there is no entry in shiftchange, time is checked.

for employees who don't have any entries to the change of the watch and work schedule, offset rule will be verified.


How in oracle?

Favorite is output

----------------------

EmpID Maj

----------------------

1                     3

2                     4

3                     3

4                     1

5                     1

----------------------

Help, please

I use oracle 10g

-----------------------

examples of data

--------------------

create table ShiftRule as

(

Select 1 as empid, 1 as passage of union double all the

Select 2 as empid, 1 as passage of union double all the

Select 3 as empid, 3 as passage of union double all the

Select option 4 as empid, passage of union of 1 double all the

Select 5 as empid, 2 in the double passage

);

create table SHIFTSCHEDULE as

(

Select 1 as empid, 4 as passage of union double all the

Select 2 as empid, 4 as passage of union double all the

Select 5 as empid, 1 as double crossing

);

create table SHIFTCHANGE as

(

Select 1 as empid, 3 as double crossing

);

Hello

Thus, each employee will be in the shiftrule table, but they may or may not be in the other tables.  This looks like a job for an outer join.

Here's one way:

SELECT r.empid

COALESCE (c.shift

s.shift

r.shift

) AS shift

Shiftrule r

LEFT OUTER JOIN shiftschedule s ON s.empid = r.empid

LEFT OUTER JOIN shiftchange c ON c.empid = r.empid

ORDER BY r.empid

;

Output:

EMPID MAJ

---------- ----------

1          3

2          4

3          3

4          1

5          1

Empid is unique in each table, as in the examples of data?

Tags: Database

Similar Questions

  • Extract only 2nd value

    Hello

    I want to extract only 2nd value of col2 that holds the values of semicolons.

    When I try his failure to appear as expected.

    Table

    col1 col2

    ------    ----------

    A cod; MOD; KL

    B; DF

    C ss; 6; 7

    D gg

    Expected results:

    col1 col2

    ------          ----------

    A mod

    B               df

    C

    D

    My test:

    with

    a trial in

    (select 'A' col1, col2 "cod;) MOD; KL' Union double all the

    Select 'B ', '; '. df"of the double

    Union of all the

    Select 'C', "ss; 6; 7' of the double

    Union of all the

    Select would be ', 'gg' of the double

    )

    Select col1,

    NULLIF (regexp_substr (NVL(col2,'~'), "[^;]")) +', 1, 1),'~ ') col2

    of the test;

    I get:

    col1 col2

    ------          ----------

    A mod

    B               df

    C               ss

    D               gg

    Any help will be appreciated.

    Thank you

    Hello

    You can also use regular expressions to get the N-th section, like this

    REGEXP_SUBSTR (col2

    , '([^;] *)(;|$)'

    1

    N - whole, to 1 or greater

    NULL

    1

    )

    SUBSTR and INSTR will be faster, however.

  • need to "extract" a numerical value of the given XML node

    My question: -.
    of a document XML how can I 'extract' a numeric value for use in a "customized math expression" to convert inches into millimetres/centimetres dimensional data?

    FYI: -.
    When you use a component XML Connector that I am able to load and display the values of XML data, of my choice, the XML document required; the data is loaded into the components that are instances of TextArea or TextInput.

    background: -.
    in order to make use of the value of XML data I tried to assign it to an 'intermediate and temporary variable' using the ComponentInstanceName.text option in an assignment, but that effort failed, where this post.

    your comments: -.
    all comments, suggestions, ideas are received with gratitude; Please keep in mind that cindy I am a newb to XML format, but hope that change in the coming months.

    Thanks for your time.

    ... and so, I discovered that the main reason for my bad be able to access the data is due to the fact that the xml data is not fully charged in my application when my code is trying to access. of course it's because of the asynchronous loading of the Flash XML Connector component behavior.

    so the repair to the original message is:-
    check that the data is fully loaded into the app and only then access and assign it to all the other required variables.

    SORTING :)

  • Extract parts of value date Selected DateField

    Hi people,

    I would like to extract the part of the year of the value selected from my datefiedl.

    For example, I would get 2010 from: 23/12/2010

    And check if the extracted year is less than the current year.

    How can I do in LiveCycle (JavaScript is better)?

    Thank you

    Yair

    var Input = Num2Date (Date2Num ($.formattedValue, JJ.)) (("" MM. YYYY '), 'YYYY')

    Var Num2Date = (date (), "YYYY")

    If (input only those) then

    xfa.host.messageBox ("bad year")

    endif

    radzmar

    http://thelivecycle.blogspot.com/

  • extract the positive values of a 2D array

    Hello

    I have a table 2D with positive value in column 2.

    What I want to do is to find the positive value of each column.

    For example, I have this table

    A        B

    -1        1

    2         -2

    3         9

    5         4

    -5        6

    6         7

    and I want to get the following

    A          B

    3          9

    5          4

    6          7

    I managed to have the positve in each case, but the value do not match (I have all the positive values of each column) as

    A AND B

    2 1
    3 9
    5 4
    6 6
    7

    can you help me please?

    Just to be clear: you want the output array to contain all rows in the input table that have positive values in the two column A and column B?  Are you using strictly positive (> 0) comparisons or not negative (> = 0)?  Are integers of values?

    RIF answers: Yes and strictly positive, this will do what you want.

    Lynn

  • How to extract the string values

    Hello

    Database: 11.2.0.3.0

    I have a JSON string like below. I want to extract only the propetyvalues. Can you help me with the query:

    {

    'documents':]

    {

    'document':]

    {

    'propertyname': 'Id',

    'propertyvalue': "{1C236CB2-AB97-4982-8117-DE0BE6D7DB46}".

    }

    ]

    },

    {

    'document':]

    {

    'propertyname': 'Id',

    'propertyvalue': "{1318AC90-C321-4D3D-9558-6547EFE49A7E}".

    }

    ]

    }

    ]

    }

    Hello

    Too bad, that you do not have version 12. Then, you can use the function JSON_VALUE mentioned previously.

    Here's something you can do in your version:

    SELECT LEVEL AS n

    , REGEXP_SUBSTR (: str)

    , ' "propertyvalue": "([^"]*) "

    1

    LEVEL

    NULL

    1

    ) AS propertyvalue

    OF the double

    CONNECT BY LEVEL<= regexp_count="" (:str,="">

    ;

    If you want to know that adapts to your specific problem, post CREATE TABLE and INSERT statements for some sample data and the exact results you want from these sample data.

  • [11g] ORA-22993 when extracted xmltype great values in the outbreak of the BIU as a CLOB in another table

    [I ask nicely for a few comments for this question.

    Someone else can reproduce it with the test below?

    Is my code invalid or false?

    Or what is the problem here?

    -Thank you

    Frank

    ]

    Hello

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for Linux: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Trigger Before Insert or Update to a table, I invoke a PL/SQL package function to check the size of an xmltype column (passing as IN OUT NOCOPY).

    PL/SQL functions retrieves the xmltype. GetClobVal(), check its size, and when it is beyond a limit, he tries to insert the data into another table (GTT - global temporary table).

    Finally, it changes the value of the value of the column of xmltype to the shorter XML (just by referring to the corresponding record in the TWG).

    But the Insert SQL in the TWG operation strike ORA-22993: specified input is greater than the amount actual source.

    I don't know why this happens. In the internet I only find references on importing files in lob/clob.

    Anyone have the same problem?

    I know that you prefer to have a sample program to demonstrate the problem - I'll try to post one, but it will take time.

    But maybe someone can help me based on the information above already.

    -Thanks a lot!

    Best regards

    Frank

    I have reproduced the issue.

    It must be a bug.

  • Extraction of multiple values

    Hi all

    I have three tables A, B, C. The query is like that

    SELECT A.TL, (by SELECTING A.AID, A.ff IN A, B, C
    WHERE A.FN = 'PA'
    AND A.AID = B.AID
    And B.code = '01'
    AND B.PID = 'B001'
    AND B.CID = C.CID
    AND C.CID = 'T001') OF A, B, C
    WHERE A.FN =' IT
    AND A.AID = B.AID
    And B.code = '01'
    AND B.PID = 'B001'
    AND B.CID = C.CID
    AND C.CID = 'T001'

    Whenevr I execute this query, I get an error message because the inner query is pulling two values which is does not match outerqueries. If someone can guide on it.

    Thank you
    HRS

    Enter this thread as answered and open a new one in the sql forum:
    SQL and PL/SQL

    Here you get a faster response.

    Thank you

  • Extract all numerical values of &gt; = 10 length

    Hi all

    I have a table named "STS_HISTORY".
    in which I have 2 fields
    Number STSID
    History varchar2 (4000)

    I need to create another table that has 2 fields
    stsid, mynum
    where stsid is the same from the table of sts_history
    and mynum will contain the numerical value of > = length 10.

    for example
    will he be stsid: 1 the history field is
    "123456789 1234567890 here 12345678901 123456789012 1234567890123 data please 12345678901234 seprate 1'
    You must then put

    1 1234567890
    1 12345678901
    1 123456789012
    1 1234567890123
    1 123456789012345

    is there way to sm to do using only does not xmltable

    of course there are:

    SQL> with sts_history as (
     select 1 stsid, '123456789 here 1234567890 is 12345678901 some 123456789012 data 1234567890123 plz 12345678901234 seprate 1' history from dual union all
     select 2 stsid, '123456789 here 1234567890 is 12345678901 some 123456789012 data 1234567890123 plz 12345678901234 seprate 1' history from dual
    )
    --
    --
    select stsid, regexp_substr (history, '\w+', 1, level) history
      from sts_history
     where rtrim (regexp_substr (history, '\w+', 1, level), '0123456789') is null
           and length (regexp_substr (history, '\w+', 1, level)) >= 10
    connect by     level <= length (history) - length (replace (history, ' '))
               and prior stsid = stsid
               and prior sys_guid () is not null
    /
              STSID HISTORY
    --------------- ---------------
                  1 1234567890
                  1 12345678901
                  1 123456789012
                  1 1234567890123
                  1 12345678901234
                  2 1234567890
                  2 12345678901
                  2 123456789012
                  2 1234567890123
                  2 12345678901234 
    
    10 rows selected.
    
  • extract values and fetch

    Hello

    I have following the result set when I have attached two tables and I want to extract values and achieve certain calculations, working with Oracle 11 g.

    For each set of values in col1, I need to extract the six values of four columns (col3, col4, col5 col6).

    Will you please help me on how to select and extract these values in PLSQL and I need calculate those values.

    For example, for a value of setting qHf in col1, I need to select values as shown below.

    a: = 97.0108212225871 (col3 value)

    b: = 32.8926555552399 (col4 value)

    c: = 97.0108906484698 (where col5 col7 value = 1)

    d: = 32.8926305735938 (where the col6 col7 value = 1)

    e: = 97.0107496352219 (where col5 col7 value = 2)

    f: = 32.8927446594943 (where the col6 col7 value = 2)

    -RESULTS OF THE JOIN GAME

    col1--col2---COL3---COL4---col5---col6---col7

    qHf--K9lN---97.0108212225871--32.8926555552399---97.0108906484698--32.8926305735938--1
    qHf--K9lL---97.0108212225871--32.8926555552399---97.0107496352219--32.8927446594943--2

    qHj--K9lH---97.0107942624454--32.8962736187889---97.0108641458855--32.8962520765163--1
    qHj--K9lF---97.0107942624454--32.8962736187889---97.0107256545409--32.8963630155553--2

    qHZ--K9nx---97.0309045000111--32.909536499905---97.0309477508092--32.9094003721652--1
    qHZ--K9nz---97.0309045000111--32.909536499905---97.0309457508092--32.9096953624556--2

    QL3--K9nt---97.0309085000024--32.9089935000592---97.0309512491911--32.9089671359185--1
    QL3--K9nv---97.0309085000024--32.9089935000592---97.0309502491911--32.9090761294466--2

    Do you want this:

    SELECT col1,

    col2,

    COL3 has,

    COL4 b,

    CASE WHEN col7 = 1 THEN END col5 as c,

    CASE WHEN col7 = 1 THEN END col6 as d,

    CASE WHEN col7 = 2 THEN col5 FINISSENT AS E,

    CASE WHEN col7 = 2 THEN col6 END AS f

    T

    COL1 COL2          A          B          C          D          E          F

    ---- ---- ---------- ---------- ---------- ---------- ---------- ----------

    qHf K9lN 97.0108212 32.8926556 97.0108906 32.8926306

    qHf K9lL 97.0108212 32.8926556 97.0107496 32.8927447

    qHj K9lH 97.0107943 32.8962736 97.0108641 32.8962521

    qHj K9lF 97.0107943 32.8962736 97.0107257 32.8963630

    ..................................

    ................................

    .................................

  • Generation of the table of all values of 30 at a time

    Hey, I measure all 30 temperature both values and generate the table of values of 30

    every minute...

    How to extract a 30 value at the same time and at the same time! I'm a problem inside!

    Here is a version with simpler data structures. Maybe this can give you some ideas.

  • Switching between the 2 sets of values controlling the axis y in a xy chart.

    All, morning

    I am very new to this (like 2 days now) and will soon sit the Labview core 1 and fundamental measure, bare with me!

    I'm basically extraction 2 string values that is issued by a Board of Directors, I have by IP, one value for line voltage and the second measure concerns the battery voltage.

    I would like the option to use a control switch to differentiate between what is entered the chart at the push of a button.

    Is there a way to do this?

    Thank you very much

    Alex

    Have you tried the Choose function?

  • Retrieve a single value from a file .lvm

    I have a large batch of files of worksheet whose name is a timestamp. I am writing a program that will get the value of a specific cell (the same cell in each file), coupled with the timestamp and each of them as a pair of coordinates, then save in a master spreadsheet. The goal is to extract a point each of the 700 files I and compile them into a single file.

    However, I've never used Labview to read the files before. I saw some stuff on how to read an entire worksheet in a table, but I was wondering if there was a way to say to Labview to look into a file and extract a single value. I open .lvm in Excel files, so, in my mind, I would be taking, for example, cell D2. Is this feasible? Should I read the entire worksheet in an array and use the index to pick it up on the table? If I do, how I would specify cell J2 as an array index (I have no experience with the berries in Labview either). In addition, if you have any tips on how to record easily 700 pairs of coordinates, that came together in the order, to a single spreadsheet, that is my next task.

    Essentially- I need to extract a single value of a spreadsheet in, ideally, the simplest possible. In addition, pointers on how to save the numbers gathered at each iteration of a while loop to a single worksheet are welcome.

    Thanks in advance for the help!

    FYI I have LabView v8.6

    You can't say LabVIEW to 'out' a specific 'cell' more you can tell Notepad to do. the .lvm files are just text files. When you open them in Excel, the column separator (default tabs) show to put the values in columns. In LabVIEW measurement file VI reading to read .lvm files. It creates the dynamic data, wrong data type that is next to useless. You will need to convert this type of data in a table by using the function convert of DDT. Or, you can use the VI read spreadsheet file. This will give you a table directly. You can just remove the specific item using the table to Index.

  • Application of feedback and a question about extraction of table

    Hello all, thanks in advance for anyone could give me any suggestions.

    I enclose a code that I have written, the code is a project to control an instrument.

    For simplicity I've substituted the signal with the random number generator.

    I would be interested to receive general feedback by people more expert than me on writing code.

    Then a question.

    The code generates a table of 10 items for each value of what I called 'Applied value' in the code.

    I'd be interested extract the last value in the array for each applied value.

    Thus, for example, if I set Start = 0, = 0.1 step and stop = 1. The size of the array will be 100, values

    I am interested to have only 10 to put in another table.

    I hope this might be clear enough...

    Thank you for your patience.

    Giuseppe.

    Hey GiuseppeTx,

    See if that's what you're going to. I have attached my edited code.

    I just added a case structure inside your loop that should do what you want. I take the picture and the length of the array and each time the while loop is about to start (i.e. the terminal Stop is set to True), I conveyed the last value in the table in an array of construction and to a new table. I also have a conditional Terminal configuration where it will transmit only data through if the case structure series 'true' State, ensuring that no data is transmitted if the case if set to false.

    I hope this helps you!

  • Comparison of values in an array

    Hello

    I have a table with 16 values, so I would like to compare the first 14 values (using the subset of table vi) table and when they are all at a distance from each other, start a clock.

    Because we measure the temperature with each of these entries in this table, once and only once, they raise spending about 100 degrees Celsius, I would begin to compare the proximity between them. Once they are all within 20 degrees celsius, on the other, this timer should start. I have the timer setting, but miss me this comparison.

    I'm really new to Labview, the only way I can think of right now, will extract each unique value, and then comparing them with each other within a while loop, but there must be a better way, right?

    Thanks in advance!

    (by the way, it's just a separate simulation I'm linking the actual program, which is why the table and some other stuff is different)

    There we go!

    Just pick up where he left in the case of false, and told to not start (or just reset) if the time was 0, which it would have been if the true case had never been moved before.

    Only problem is now that the present (s) is not reset to its default value 0 after I press stop, but since this would only return to the top once and the program would shut down, then restarted another day, it will not be a problem. And a friendly warning to remember to write 0 on the control if it were to start again would also go a long way. Overall, I am satisfied.

    Thanks for the help!

Maybe you are looking for