Using nested switch/case statements

What is the best practice of two following switch/case statements?

Is there an easier way (less code) to do this?

Thank you.

I think it's as clean as it gets:

Tags: Flex

Similar Questions

  • How to track down where a specific enum is used in a switch case statement?

    Hi all

    I have an application of simulation of machine quite complex state that I add a 'mode' feature for. Some States in the application, rather than the blocks by default of running code, a VI a VI class for each mode will be instead (for example for modes A and B, initialization status has now Initialization_modeA and Inilitalization_modeB). This results in many cases structures everywhere, and I can't figure out how to ensure that, when adding a new mode, I have add the case of this mode of each switch case. Is it as simple as having a default case with a pop-up box? Or is it possible OOP I can handle this?

    Go right on what you told us, you could have each mode inherited from a common ancestor that defines a set of common States (or methods in this case). Whenever you want to add a new method, you can create a new class and override simply each method with this specific class has to do. Instead of having a State of init for each mode, you only then a common State of init, which would then distribute the code correct init based on what class you are using.

  • using nest if then statements using ABM

    I have a two input, 1 output circuit, as in the attached schema. My third node is set down by the very high resistance voltmeter. What I have is a user defined current source ABM that depends on other parameters in the circuit. I wonder it is what my conditional statement is entered in the right format? Conditions are particularly complex and describe as follows:

    If the voltage difference between V2 and U1 is greater than 0, then the current in the ABM = 10 ^-12

    If this voltage difference that the above is not greater than zero and if (V (1) u (1))<(V(2)-U(1)), then="" the="" abm="" current="" is="">

    Otherwise, if (V (1) u (1)) > = (V (2) u (1)) then the current is (0.1*((-(V(2)-U(1)))^0.35))*0.00001596*(((V(2)-U(1))^2)/2)

    As you can see, they are very complex conditions and my concern is that I can't just type in U1 and get the compiler to understand I want the voltage read on the voltmeter of bottom-node. I think I'm using the correct nesting in the encoding format is: if (T, X, (if(Q,R,S))).

    Any help would be appreciated, and details can be provided.

    I don't know why its not throwing an error for the use of u (1), maybe it's a valid keyword.

    If you want to reference a voltage properly, it should be V (net_name) for single ended voltages (referenced to ground) or V (net1, net2) for differential voltages... For models ABM I suggest turning on net visibility throughout the schematic so that you know the net name to the positive terminal of U1 or anywhere else for that matter.

    I think the syntax you have to if/then/else is correct otherwise.

    Kind regards
    Pat Noonan
    National Instruments

  • Using the conditional case statement. !

    Hello Forum members.

    I have a table with order of stores as well as the order dates and other information. I have a requirement to write a request for nominations for the roll of the order according to the below mentioned logic.

    Name1 = Initial order date and next order within 7 days of the original order date then its considered R1

    Name2 = next activity within 7 seven on the ord_id even of its R1 to date, this is going on as increases in order to ord_no simple or even dates

    .

    .

    Final RN is Count (Rn)

    RN %--Count(Rn) / Count Distinct (ord_no) * 100

    Sample data output:

    ORD_DATEORD_ID1_of_x2_of_x3_of_x4_of_x5_of_x6_of_xFinal RnXRN %
    10/07/201310095V1100000
    03/08/201310095V1100000
    08/08/201310095V1010000
    12/08/201310095V1001000
    06/09/201310095V1100000

    DDL:

    create the table xx_ord_noms

    (

    ord_no varchar (30),

    ord_date date,

    ord_id varchar2 (30)

    );


    Sample data:

    INSERT INTO xx_ord_noms (ord_no, ord_date ord_id) VALUES ('10091', TO_DATE('07/10/2013','MM/DD/YYYY'), ' 10091');

    INSERT INTO xx_ord_noms (ord_no, ord_date ord_id) VALUES ('10091', TO_DATE('08/03/2013','MM/DD/YYYY'), ' 10091');

    INSERT INTO xx_ord_noms (ord_no, ord_date ord_id) VALUES ('10091', TO_DATE('08/08/2013','MM/DD/YYYY'), ' 10091');

    INSERT INTO xx_ord_noms (ord_no, ord_date ord_id) VALUES ('10091', TO_DATE('08/12/2013','MM/DD/YYYY'), ' 10091');

    INSERT INTO xx_ord_noms (ord_no, ord_date ord_id) VALUES ('10091', TO_DATE('09/06/2013','MM/DD/YYYY'), ' 10091');

    commit;

    I was intending to do something like that, but I don't get the logic for R1... R7

    Select ord_no,

    ord_date,

    ord_id,

    prev_dt,

    (to_date (ord_date) - to_date (prev_dt)) data_diff,.

    case

    When prev_dt is null or

    (to_date (ord_date) - to_date (prev_dt)) < 7 then

    'R1 '.

    When (to_date (ord_date) - to_date (prev_dt)) > 7 THEN

    "R2".

    ON THE OTHER

    nULL value

    END

    FROM (select a.*,

    (SELECT MAX (tmp2.ord_date)

    OF xx_ord_noms tmp2

    WHERE a.ord_id = tmp2.ord_id

    AND tmp2.ord_date < a.ord_date) prev_dt

    of the xx_ord_noms one).

    Could someone give advise me or suggestions on how we can achieve the desired results.

    Thanks in advance.

    LAG and LEAD are good when you want to look forward or back up a fixed number of lines, but in this case you do not know how far behind, you will need to go.

    I have a solution. It calculates the Royal Navy in number, not a position of the column, but you can turn it with instructions BOX if you want to. I did it in two steps:

    First of all, I calculated the Royal Navy by comparing the date of the current and previous line. To do this, I have generated a line number using row_number() Analytics:

    Select ord_no,

    ord_date,

    ord_id,

    numrow

    Rn

    of xx_ord_noms

    model

    partition (ord_no)

    dimension (row_number() over (partition by order of ord_no of ord_date) numrow)

    measures (ord_date 0 Rn, ord_id)

    update rules

    (

    RN [1] = 1,

    RN [ANY] BOX when trunc (ord_date [cv ()]) = - trunc (ord_date [cv () - 1])< 7="" then="" rn[cv()-1]+1="" else="" 1="">

    )

    ORD_DATE ORD_ID NUMROW RN ORD_NO

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

    10091 10 July 2013 00:00:00 10091 1 1

    10091 3 August 2013 00:00:00 10091 2 1

    10091 August 8, 2013 00:00:00 10091 3 2

    10091 12 August 2013 00:00:00 10091 4 3

    10091 2013 - Sep - 06 00:00:00 10091 5 1

    Then I needed to identify all the lines of each series. I defined firstDt as the date of the first item in the series:

    firstDt [1] = ord_date [cv ()]

    firstDt [ANY] = CASE when rn [cv ()] = 1 then ord_date [cv ()] to another firstDt [cv () - 1] end

    With that, the FinalRn is just a max (rn) Analytics (firstDt score)

    I'm not clear on what R % is. Your descriptions are not clear and I think they are incompatible.

    Select ord_no, ord_date ord_id

    , Rn, finalRn, 100 * finalRn/totCnt PCT1, 100 * totRn/totCnt PCT2

    totRn

    of xx_ord_noms

    model

    partition (ord_no)

    dimension (row_number() over (partition by order of ord_no of ord_date) numrow)

    measures (ord_date, 0 Rn, ord_id, to_date (null) firstDt, 0 finalRn, 0 totRn, 0 totCnt)

    upsert rules all the

    (

    RN [1] = 1

    RN [ANY] BOX when trunc (ord_date [cv ()]) = - trunc (ord_date [cv () - 1])< 7="" then="" rn[cv()-1]+1="" else="" 1="">

    firstDt [1] = ord_date [cv ()]

    firstDt [ANY] = CASE when rn [cv ()] = 1 then ord_date [cv ()] to another firstDt [cv () - 1] end

    [ANY] finalRn = max (rn) on (firstDt score)

    totCnt [ANY] = count (*) over()

    , totRn [ANY] = count (case when rn = 1 then 1 other trailing null))

    )

    ORD_DATE ORD_ID RN PCT1 PCT2 TOTRN FINALRN ORD_NO

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

    10091 10 July 2013 00:00:00 10091 1 1 20 60 3

    10091 3 August 2013 00:00:00 10091 1 3 60 60 3

    10091 August 8, 2013 00:00:00 10091 2 3 60 60 3

    10091 12 August 2013 00:00:00 10091 3 3 60 60 3

    10091 2013 - Sep - 06 00:00:00 10091 1 1 20 60 3

    Kind regards

    David

  • How can I get the nested case statements to work with listagg?

    I have a statement below that does not work as I want it, here is my code:

    Select

    cases where o.personal_label is not null

    then

    listagg (cases where s.subcodevalue like '% MON %')

    then s.subcodevalue |' '|| o.personal_label

    of other s.subcodevalue

    end,': ')

    the Group (order of s.subcodevalue) as subcodevalue

    on the other

    listagg (s.subcodevalue,': ')

    the Group (order of s.subcodevalue) as subcodevalue

    end

    of mtm_styles_new s, order_mtm o

    where INSTR (o.extras, s.code) > 0

    and o.bodyfitting = s.bodyfitting

    and o.division = s.division

    and s.subcodevalue is not null

    and o.ORDER_MTMID = 'somevalue '.

    It should bring the following

    * MY TEST: RPP

    or the following if the first case is not completed:

    * MONDAY: RPP

    I get an error message saying 'missing keyword', but cannot make out where, can someone please help me here?

    The following works fine as long as it is not a nested case statement, but I need to nest the case statement:

    Select listagg (cases where s.subcodevalue like '% MON %')

    then s.subcodevalue |' '|| o.personal_label

    of other s.subcodevalue

    end,': ')

    the Group (order of s.subcodevalue) as subcodevalue

    of mtm_styles_new s, order_mtm o

    where INSTR (o.extras, s.code) > 0

    and o.bodyfitting = s.bodyfitting

    and o.division = s.division

    and s.subcodevalue is not null

    and o.ORDER_MTMID = 'somevalue ';

    Out alias 'subcodevalue as' the case at the end of the case body.

  • case statement for States

    Hi all

    I am filling a text field based on what the user chooses a drop down which contains the 50 United States of America.

    So... Let's say for now I mean 'Birmingham' if the user selects "Alabama", the text field.

    The only thing I have at the moment is completely false:

    setText() function

    {

    var statechoice = State.value;

    Switch (statechoice) {}

    case 1:

    Text1.RawValue = "deposit is required in Alabama."

    breaking

    case 2:

    Text1.RawValue = "very cold and the deposit is required in Alaska."

    breaking

    by default:

    Text1.RawValue = "choose a please state";

    breaking

    }

    Must it always be the case 1, 2, 3 and so on? It can never be "case (something is true and something is equal to 7):?  I mean, what I always use integers to distinguish the cases?
    later I want to fill down based on choices that makes the user. I want to have a list of conditional statements where each conditional expresses a unique combination of choice that the user has made.
    Do you like cold food? Yes
    Lactose intolerant? NO.
    Field of text says "having a cone of ice cream for dessert."
    How can I get integer values in a drop-down? DropDown.Value? DropDown.index? dropdown.selectedIndex?
    How to combine these choices in the instructions box? If (dd1 = 1 and 4 = dd2 and dd3 = 2):?
    Sorry for this discursive question,
    I just need a good example to follow.
    Thank you very much
    Joe

    You can try something like below...

    Otherwise, the Switch statement only evaluates to the value that is passed next to the switch control...

    var statechoice = State.rawValue;
    Switch (statechoice) {}
    case "AL":
    Text1.RawValue = "deposit is required in Alabama."
      Text1.RawValue = Text1.rawValue + setText();
    break;
    case "AK":
    Text1.RawValue = "very cold and the deposit is required in Alaska."
    break;
    by default:
    Text1.RawValue = "choose a please state";
    break;
    }

    Added a function inside the same event and call this function in the switch case statements above.
    function setText() {}
    Switch (otherDropDown.rawValue) {}
    case study "Yes":
    return "selected Yes;
    break;
    by default:
    Return "No selected ';
    break;
    }
    }

    I hope this helps...

    Thank you

    Srini

  • How can you change a menu drop-down menu in a case statement?

    Hello

    I'm trying a table find vi. This VI will be an existing xml file and once the user has selected access to its equipment, input, output and frequency it put all of these options in a string and search the XML for this exact table name and post it on one screen of output. The problem I have is my entry and exit selection must be a little different depending on the chosen equipment. I thought I could use an instruction box to change the options of selectable input and output, but I ran into snags a lot with it. For whenever I have to put a new drop of entry and exit in the drop-down menu in the case statement, he wants to put a new one in the front (I only want to enter and exit not only three I have two inputs and outputs hidden right now). I think I'm using the wrong case statement... Can someone help change my input and output, selectable options depending on the chosen equipment. Attached is my xml file, Array Find.vi (the original) and table Find_Test.vi (that's what I'm trying to change).

    Thank you

    dlovell

    Hi dlovell,

    A few changes in the attached VI:

    Requirements/possible Solutions

    • When the value of the equipment, do something
      • Add the cases to the value of equipment change event
    • Do something = decide what channels to write, to change the input and output strings
      • Read material value changed
      • Decision (case structure)
      • Channel (same method as the previous mod)

    Hope this helps

  • Case statement in the SQL Query prompt dashboard

    Hi Experts,

    I use the following case statement to generate default values in the prompt dashboard based on a condition (the other guest-generated values). Below are two of the query I've tried and the syntax error. I tried all the possibilities (like giving apostrophes, double quotes, don't quote not etc.), but could not understand the question. Don't know what exactly I'm missing here.

    Query 1:

    SELECT

    CASE

    WHEN @{PRType} = monthly THEN 'Participant pay '. "" Amount of PayRate "="15000"

    WHEN @{PRType} = daily THEN 'Participant pay '. "" Amount of PayRate "="650"

    WHEN @{PRType} = hourly THEN 'Participant pay '. "" Amount of PayRate "="1"

    ELSE ' 0'

    END

    OF 'PA-Participant pay. '

    Query 2:

    SELECT

    CASE

    WHEN @{PRType} = monthly THEN "15000"

    WHEN @{PRType} = daily THEN "650"

    @{PRType} = schedule THEN '1'

    ELSE ' 0'

    END

    OF 'PA-Participant pay. '

    This is the query that is generated in the log with error message file.

    1 log message:


    SELECT CASE WHEN Hourly = Monthly THEN "Participant Payroll"."Payrate Amount" = '15000' WHEN Hourly = Daily THEN "Participant Payroll"."Payrate Amount" = '650' WHEN Hourly = Hourly THEN "Participant Payroll"."Payrate Amount" = '1' ELSE '0' END FROM "PA-Participant Payroll"

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>=: Syntax error [nQSError: 26012]. (HY000)



    Comment 2:

    ;CASE WHEN To_Char (Hourly) = 'Hourly' THEN 1 ELSE 0 END 

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>(): syntax error [nQSError: 26012]. (HY000)

    Sorry, I wasn't clear... you must always put this CASE statement in a valid SQL SELECT statement.

    SELECT

    CASE

    When ' @{PRType}' = 'Monthly' THEN '15000'

    When ' @{PRType}' = 'Daily' THEN '650'

    ELSE '0' END

    OF 'PA-Participant pay. '

  • using nested case statement does not get the right result

    Hello all;

    I have a sample of data similar to below
    create table t3
    ( 
           id varchar2(200),
           qty number(30),
           qty2 number(30)
    ); 
     insert into t3
       (id, qty, qty2)
     values
       ('A', 10, null);
     
      insert into t3
       (id, qty, qty2)
     values
       ('A', 20, null);
       
     insert into t3
       (id, qty, qty2)
     values
       ('B', null, 5);
       
    insert into t3
       (id, qty, qty2)
     values
       ('B', null, 5);
       
     insert into t3
       (id, qty, qty2)
     values
       ('C', null, -5);
       
    insert into t3
       (id, qty, qty2)
     values
       ('C', null, 5);
    
    
     insert into t3
       (id, qty, qty2)
     values
       ('D', -1, -2);
       
    insert into t3
       (id, qty, qty2)
     values
       ('D', 1, 4);
    This is what looks like data
    ID  QTY  QTY2
    A    10
    A    20
    B              5
    B              5
    C             -5
    C              5
    D    1        4
    D   -1       -2
    It is the output that I desired below
    ID    Status 
    A      Fail
    B      Fail
    C      Pass
    D      Fail
    A is a failure because the sum of the 2 has the value zero, where the summation of the qty was used to determine the State and because the sum of the quantity is not equal to zero, then, it is a failure
    D is a failure because even if the sum of the Qty 1 equals zero, we must make use of summation of the qty 2 instead because he is not null to determine the status and the summation of the qty is 2, where a failure
    etc.

    I tried write something but can not make it work
    select case when sum(v.qty) is not null
                and sum(v.qty) = 0 then 'Pass'
                when sum(v.qty) is not null
                and sum(v.qty) != 0 then 'Fail'
           else
             case when sum(v.qty2) is not null
               and sum(v.qty2) = 0 then 'Pass'
               else
                when sum(v.qty2) is not null 
                  and sum(v.qty2) != 0 then 'Fail'
                  end as status
              end as status
    
    
     from t3 v;
    any help is appreciated. Thank you.

    Try this,

    SELECT ID,
           CASE WHEN NVL(SUM (qty2),1) !=0 THEN 'fail'
                WHEN NVL(SUM (qty),0) != 0 THEN 'fail'
                ELSE 'pass'
           END
      FROM t3
    GROUP BY ID
    
    OUTPUT
    -------------
    
    ID RESULT
    -- ------
    A  fail
    B  fail
    C  pass
    D  fail
    Z  fail
    

    G.

  • Use the control of timing DAQmx as input in case statement

    Hello

    I'm building a VI aquire sampled under tension of a sensor in continuous mode or finished.  I was going to do this, use a box with a cable of the sample mode of the VI DAQmx calendar entry to the terminal State, the idea being that I couldn't aeither a while looping the case for continuous or simple acquisition according to the setting of this command.

    However, instead of the sample mode provided for in the case of the case statement, I just get 1 and 0.

    It's a good way to achieve this, and if so how can I get my case structure working properly?

    Thank you

    Dave

    Hi Dave,.

    Apologies - I consider that the error is from the data acquisition function? I forgot that she was using the sample entry mode.

    Perhaps, then, it will be preferable to continue using the control of the ring - cases will be numbered and will correspond to the numeric value of the selection of the ring (i.e. finite samples = 0). I have attached a small example if we know not.

    Moreover, the structure of the case cannot automatically fill for each case, in which case you can right click on the structure of the case-> add the case after.

    Best regards

  • Can I use a hexadecimal string with a case statement?

    Simple question:

    Can I enter a hexadecimal string to a case statement and have the case statement see it as hex?

    I understand that I could convert the hexadecimal string to a number and then enter the hexadecimal number to the case statement but I am curious to know if I could have the case see the string itself as hex without this added feature.

    Would be nice to not have to convert all my numbers throughout my code strings

    Thank you

    -Eric

    How long are the strings? Since you mention convert in numbers, they are probably short and all of same length.

    Are there different possible channels how?

    Case header includes \-codes in the case of a label deal selector As string, so that should be enough for your use. For example this code turns the LED (.. .so that a simple string of "\00\00" of wiring would not be!)

    (See also the last sentence of the "enumerated values" section of the help).

  • definition of variables in packages and using the same variables in charge Plans as a case statement in Odi

    Hello

    I am trying to use a global variable 'Global.test' in my ODI "pkg_test" package and step declaration type as a variable that is defined with the value 1 when my package evaluates the condition successfully run and with 0 if the fails.now condition I will carry out the same "pkg_test" package in my load "LP_TEST" and using the variable 'Global.test' Plan as a case statement in terms of load "LP_TEST".

    It's workload Odi is unable to understand the value of the variable 'Global.test', which is defined in my pkg 'pkg_test' and my case statement is put down in my care Plan.

    Thank you

    Hi Santosh Pradhan,

    What kind of story do you have in your variable?

    If you have not selected any antecedent, the scope of the variable is limited to the session. As the execution of the package is a session in its own (independent of the workload performance), the value of the variable is not accessible after his execution.

    You can also try assigning / updating of the value of the variable directly from your plan, instead of in the package:

    It will be useful.

    Best regards

    JeromeFr

  • I have problem with value NULL when the use CASE statement please help this question

    I have problem with value NULL when the use CASE statement please help this question


    Table: digital_val

    SNO cl C2

    1 San1 11

    2 22 San2

    Actual result: expected to A         B

    A            B                                                                           11        22

    11 NULL

    22 NULL



    query:

    Select case when c1 = "san1" then c2,.

    case If c1 = "san2" then c2 B

    of digital_val

    I'm more curious why, when you select 2 rows, you expect a result of row?

    WITH digital_val

    AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)

    UNION ALL

    2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)

    SELECT CASE WHEN c1 is "San1" THEN END AS A c2.

    CASE WHEN c1 = "San2" THEN END AS B c2

    OF digital_val;

    With no other input, if you select 2 rows, you get 2 rows.  One of the other solutions use a max function, but is this really what you want, does not specify?

  • using a Case statement to display the values of column even as table headers

    I have a database that has been set up kind of tricky, in that some tables are made up of columns that are field names and one link to another table that contain the data for these field... also names there ID displays as many lines instead of as a row of data. I would like to write a query to extract that information and display it as one line for each ID.

    example: table 1

    ID, name, itemresponse and itemcode, Description

    Dee Jones Childrens Hospital 123 SITE location

    123 dee Jones, Date of appointment next NEXTAPPT 22/04/2014

    123 dee Jones was on bedrest NOSHOW reason do not show

    I would like to have the display of data as a record on this same patient, instead of as 3 separate registers (with the Description column in table 1

    Table 2

    ID, name, place, Date of the next meeting, show no reason

    123 dee Jones Childrens Hospital 22/04/2014 was the bed rest

    I have included the code I worked on below my question, for me to get the desired results should I use the Case statement and it's the right way to do it below?

    (SELECT
    PAT.ID "PATIENT ID."
    PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
    PAT. "PATIENT DOB," DATE_OF_BIRTH
    DS. Date 'Date of inpatients ',.
    Dai. ITEM_CODE "Item Code",
    Dai. DESCRIPTION "Description."
    Siad. ITEM_RESPONSE,

    Max (CASE WHEN dai. ITEM_CODE IS "SITE" THEN DAI. Decription
    ANOTHER NULL
    END) AS "name of the hospital."

    Max (CASE WHEN DAI.) ITEM_CODE IS 'NEXTAPPT' THEN DAI. ITEM_Description
    ANOTHER NULL
    END) AS 'next Appt Date. "

    Max (CASE WHEN DAI.) ITEM_CODE IS "LASTDATE" THEN DAI. Description
    ANOTHER NULL
    END) AS 'last visit Date.

    Max (CASE WHEN DAI.) ITEM_CODE IS 'NOSHOW' THEN DAI. Description
    ANOTHER NULL
    END) THAT "the reason has not shown".

    Of
    (PAT.ID "IDENTIFYING PATIENT",
    PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
    PAT. "PATIENT DOB," DATE_OF_BIRTH
    DS. Date 'Date of inpatients ',.
    Dai. ITEM_CODE "Item Code",
    Dai. DESCRIPTION "Description."
    Siad. ITEM_RESPONSE

    Of

    dm_sessions Ds,
    dm_session_assessments dsa,
    DAS dm_admin_sections,
    dm_session_assessment_items Siad,
    Dai dm_admin_items,
    Po Patient_Orders,
    Inventory inv,
    Patients_Table PAT
    dm_admin_categories CAD

    where dsa.session_Id = ds.session_Id
    and PAT.ID = ds. Patient_ID
    and dsa.excluded_assessment =' no
    and dac.category_code = 'OPEN'

    and dsa.section_id = das.section_id
    and das.category_id = dac.category_id
    and das.section_code = 'northwest'
    and dai.section_id = das.section_id
    and dsai.item_id = dai.item_id
    and dsai.session_assessment_Id = dsa.session_assessment_Id
    and dsai.excluded =' no
    - and Dai.ITEM_ID = Dsai.ITEM_ID
    and Dai.ITEM_CODE IN ('SITE', 'NEXTAPPT', 'LASTDATE', 'NOSHOW')
    and po.patient_ID = ds.patient_ID
    and in. NDC_NO = inv. NDC_NO
    and inv. TDRUG_ABBREV = in. DRUG_ABBREV

    PAT.ID GROUP, PAT. FIRST | » '|| PAT. LAST, PAT. DATE_OF_BIRTH, ds. Date, dai. ITEM_CODE, dai. DESCRIPTION, Siad. ITEM_RESPONSE))

    Hello

    DATE is not a very good name for a column.  Use something like EVENT_DATE, that will not be confused with a keyword from Oracle, instead.

    I don't see something like this column in the CREATE TABLE statement.  He will always be the same value on all lines?

    Here's a way to get the results you requested:

    SELECT id

    first name | ' ' || LastName AS name

    Date of birth

    MAX (CASE WHEN item_code = "NEXTAPPT", THEN item_response END) AS next_appointment,

    MAX (CASE WHEN item_code = "LASTDATE" THEN item_response END) AS last_visit_date,

    MAX (CASE WHEN item_code = "SITE" THEN item_response END) AS location

    FROM mytable1

    GROUP BY id, firstname, lastname, dob

    ;

    Of course, I can't test it very well until you post INSERT statements for the sample data.

    I guess that 2 or more lines of the entry have the same id, then they will necessarily be first name last name, the name and date of birth, too.  No doubt they are standardized in your actual tables.

  • using the case statement


    Hello

    How can I convert a code for the below sql case statement:

    If)

    (length of (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < = 0 OR tmp_co_orig_val == 1 OR tmp_co_orig_val > = 9999999)

    OR

    ((tmp_co_orig_val == 999999 AND (length of (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15)))

    Start

    tmp_collatvalue = «»

    tmp_msg_cd = 115

    end

    Is the case statement below that I wrote is correct. I don't have an environment now to test.  Please advice.

    BOX WHEN (CHAR_LENGTH (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < 0 OR tmp_co_orig_val = 1 OR tmp_co_orig_val = > = 9999999)

    OR (tmp_co_orig_val = 999999 AND (CHAR_LENGTH (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15))

    THEN tmp_collatvalue IS NULL AND tmp_msg_cd = 115

    END

    Hello

    937454 wrote:

    Thanks Frank. Really helps. But I have to write a sql statement

    But can you also specify, if I made a mistake in my code, or it's ok.

    There are no CASES reported in Oracle SQL.

    Oracle SQL has BOX expressions, but they only return a single value.  You cannot set 2 columns in the same expression BOX.

    Perhaps the best thing to do in pure SQL for you is to write a CASE expression, very similar to the CASE statement above, in a subquery and use the results of this in 2 separate expressions of BOX (very simple) in a Super application.

Maybe you are looking for

  • Satellite S2400: "Block 1 BIOS is corrupted" Error Message at startup

    Hello my laptop S2400-103 does not start, instead it gives my the error message mentioned above and request a disk "interview." How can I fix? I downloaded 2 updates of BIOS for this model, but they both require a Windows system running. Thank you Ha

  • How do I report counterfeit software

    Unfortunately, I fell victim of rogue software, I have tried to report to report counterfeit Microsoft but when I enter the license code, microsoft says that it is a valid product key, so I'm not able to continue to the next page to complete the repo

  • Windows Media Player cannot play the CD.

    When I try to play a pre recorded cd, I get the following message. (Windows Media Player cannot play the CD. The disc may be dirty or damaged. Turn on error correction and then try again) I tried another disk drive, but I get the same results. Can so

  • MY HP PRINTER

    How to control the speed of the printer HP DESKJET F2235?my Windows 7 operating system.

  • problem with my emails

    Dear Sir.I have a problem opening my emailsand I can not also for them deletso in these two subjects, what shall I do?Please can I have an answerconcerning