need help for query with case

Hi, I have the following requirement based on the terms
Here's the test tables and data
create table test_r_cd (id , role_code,org_id)
as 
select 100,'LOC' ,10 FROM DUAL UNION ALL
select 100,'LIQ',20  FROM DUAL UNION ALL
SELECT 100,'STE' ,30 FROM DUAL

CREATE TABLE TEST_SEC_TYP(id,type)
as
select 100,1 from dual union all
select 100,2 from dual 


select * from
test_r_cd cd ,TEST_SEC_TYP typ
where cd.role_code in (case when (typ.type =1 )
                                         then ('LOC','LIQ')
                                         when (typ.type = 2) 
                                         then ('STE') 
                                         ELSE null
                                         end )
The expected output is:
org_id   role_code   type
10            'LOC'        1       
20            'LIQ'         1      
30            'STE'        2    
Thank you
SQL> select *
  2  from test_r_cd t1,test_sec_typ t2
  3  where t1.ID = t2.id
  4  and case when role_code in ('LOC','LIQ') then 1
  5           when role_code = 'STE' then 2
  6           else null end = t2.type;

        ID ROL     ORG_ID         ID       TYPE
---------- --- ---------- ---------- ----------
       100 LOC         10        100          1
       100 LIQ         20        100          1
       100 STE         30        100          2

Tags: Database

Similar Questions

  • Need help for query flat_file type clobdata oracle table data.

    Hi Sir,

    I need help to query oracle table flat file data having given clob type.
    Oracle Version:
    
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    
    
    
    Source table
    
      CREATE TABLE order_details 
       (     QUEUE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         LINE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, 
         CHAR_DATA CLOB, 
         OPTIMISTIC_LOCK_KEY NUMBER(20,0)
       ) 
    COLUMN FOR CHAR_DATA FLAT_FILE
    EU,6067AT,AT10,000000402004,NexiumGERDManagementProject,Z435,,ZZ29,NIS-GOLD,AT
    EU,6067AT,AT10,000000402038,NIS-OEU-ARI-2007/1,Z450,,ZZ29,NIS-OEU-ARI-2007/1,AT
    EU,6067AT,AT10,000000402039,SymbicortNISinCOPD,Z450,,ZZ29,NIS-REU-DUM-2007/1,AT
    EU,6067AT,AT10,000000402040,D1443L00044SeroquelXRRuby,Z450,,ZZ29,D1443L00044,AT
    EU,6067AT,AT10,000000402041,NIS-GEU-DUM-2008/1,Z450,,ZZ29,NIS-GEU-DUM-2008/1,AT
    EU,6067AT,AT10,000000402042,SonstigeAktivitätenLCM,Z450,,ZZ29,.,AT
    EU,6067AT,AT10,000000402134,D1680L00002Saxagliptin,Z450,,ZZ29,D1680L00002,AT
    EU,6067AT,AT10,000000402199,SeroquelWaveNIS,Z450,,ZZ29,NIS-NEU-DUM-2009/1,AT
    EU,6067AT,AT10,000000402313,SeroquelExtra(D1443L00082),Z450,,ZZ29,D1443L00082,AT
    EU,6067AT,AT10,000000402517,AtlanticD5130L00006(AZD6140),Z450,,ZZ29,D5130L00006,AT
    EU,6067AT,AT10,000000554494,ArimidexSt.Gallen(13+2),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554495,ArimidexASCO(5delegates),Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554496,ArimidexSanAntonio6delegates,Z142,,ZZ09,,AT
    EU,6067AT,AT10,000000554497,ArimidexBreastCancerSummit(13+2),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554498,ArimidexEIH(15delegates),Z130,,ZZ09,,AT
    EU,6067AT,AT10,000000554499,ArimidexNIFA(200delegates),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554500,ArimidexNIFAworkshops(8x25),Z135,,ZZ09,,AT
    EU,6067AT,AT10,000000554501,ArimidexPraktischeGyn.Fortbildung,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554502,ArimidexAGO,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554503,ArimidexHämato/OnkologieKongress,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554504,ARIMIDEXGYNäKOLOGENKONGRESS,Z147,,ZZ09,,AT
    EU,6067AT,AT10,000000554505,ArimidexChirurgenkongress,Z147,,ZZ09,,AT
    EXPECTED RESULTS:
    AFFIRM_CODE COMPANY_CODE INTERNAL_ORDER_CODE INTERNAL_ORDER_DESC ENIGMA_ACTIVITY             SUB_ACTIVITY_CODE IN_AFF_IND ORDER_TYPE EXTERNAL_ORDER COUNTRY        
    EU          6067AT       AT10                 000000402004       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             
    EU          6068AT       AT11                 000000402005       NEXIUMGERDMANAGEMENTPROJECT     Z435           NULL        ZZ29       NIS-GOLD        AT             

    Sorry, my bad. Without database at hand, I'll try 'baby steps' (borrowed from Frank) so you don't confuse it with errors that I might add (happens far too often already, but at least you won't "swallow" as forum members think is one of the main goals of this fighter - help her learn - providing not only the proverbial fish.)
    Search the Forum - your problem is one of its best sellers. Watching {message identifier: = 10694602} ("split string into" was the key word used in research) you can try something as

    select table_row,
           level clob_row,
           regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) the_line
      from (select to_char(queue_seqnum)||':'||to_char(line_seqnum) table_row,
                   char_data
              from order_details
           )
     connect by regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) is not null
            and prior char_data = char_data
            and prior table_row = table_row
            and prior sys_guid() is not null
    

    to get all the s the_lineall CLOB and after that the use of the example even to get your columns of each the_line.

    Concerning

    Etbin

    Edited by: Etbin on 3.2.2013 09:01

    .. .but I m connected to do things according to the instructions, I can't do something.

    Used to happen to me too and I did as told to the but only after explaining any disadvantages, I was aware of in time. The last sentence is usually: "O.K. now be just and Don't come back with that kind of thing when it turns out that this isn't the right thing."
    rp0428 post - something to remember.

  • I need help for query AVG

    I need help with a simple query in an ORACLE database. I tried a lot of things that I found on the internet, but none of them worked for me.

    The following query retrieves four lines:

    SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3

    Of asw_lab

    WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM < 5

    ORDER BY sampled_date DESC;

    I would like to calculate a moving average of the last four values with the date of the sample of the last line.

    For example, I have this result for the query above:

    Value1 value2 value3

    01/04/14-16:00 1 0

    01/04/14 15:00 2 0

    01/04/14 14:00 3 0

    01/04/14 13:00 4 0

    I want to extract the below my average/query calculation result:

    Value1 value2 value3

    01/04/14-16:00 2.5 0

    Can you help me create a request to that effect?

    Thank you

    Maybe it's

    Select max (VALUE1) VALUE1, VALUE2 avg (VALUE2), avg (VALUE3) value3

    Of

    (

    SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3

    Of asw_lab

    WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM<>

    )

  • Need help on query with decimal places and trailing 0

    Community of Oracle I need help in the following situations:

    I received the following query:
    SELECT (SUM ("VALUE1") COUNT ("VALUE2"))
    FROM sometable;

    This returns the following results:
    200
    222,5

    I want to display as 222.50 222,5 value so I tried ROUND(value,2) but then came to the conclusion that the tour will not show drags me 0.
    So now I tried to_char(value,'9999DD00') and of course he's back 200.00 both 222.50.

    Now how to make it conditional so when a number has no decimal place it shows the whole number and when it has a decimal, it shows it in the format to_char(value,'9999DD00')?

    I hope I have made my situation and question correctly and I hope a solution.

    P. S.
    I need to appear like that since it is an average of the prices of the products

    Published by: Jnijman on July 3, 2010 13:06

    You can use CASES and INSTR:

    SQL> with t as ( -- generating sample data:
      2  select 200 col from dual union
      3  select 222.5 from dual
      4  )
      5  --
      6  -- actual query:
      7  --
      8  select col
      9  ,      case
     10           when instr(col, ',') > 0
     11           then to_char(col, '999d00')
     12           else to_char(col, '999' )
     13         end formatted_col
     14  from   t;
    
           COL FORMATT
    ---------- -------
           200  200
         222,5  222,50
    
  • Need help for query joining views

    Hi all

    I need to run a query that joins a number of tables with multiple instances of the same view.  For example, a view named MY_VALUES, is an array of key / value resembles the following:

    Application_ID Attirbute_Description value

    1 1 000 basic benefit

    1 multiplier 1 0.5

    1 Multiplier_2 1.2

    1 total profit 1,115

    2 1 025 basic benefit

    2 multiplier 1 0,268

    2 Multiplier_2 1.3

    Total profit 2 1.4500

    Say I want a query that selects basic earnings and a multiplier 1 for Application ID 1, as well as, other information from a table called APPLICATION that has a relationship to display pk - fk. I would do the following:

    Select the application. Name, mv1.value, mv2.value

    from dbo. App APPLICATION, dbo. MY_VALUES mv1, dbo. Mv2 MY_VALUES

    where app.id = mv1.application_id and mv1.attribute_description = "Basic benefits"

    and app.id = mv2.application and mv2.attribute_description = id 'multiplier 1'.

    and app.id = 1

    My actual query is similar to this. However, I have many other attributes of the notice I need to select, which requires that the view be attached to several times. After 16 these joins, the request is fine. After 17, however, the query runs always, never return a result within 45 minutes I have let it run.

    Is there a better way to write such a request or an indicator of optimization that would be useful here?

    Any help is greatly appreciated.

    ....

    For this type of application, it is often best to extract multiple lines in a single request on the view and their pivot in the output.

    For example

    Select the application. Name

    , max (CASE when mv.attribute_description = "Core service" then mv.value any other purpose) BaseBenefit

    , max (CASE when mv.attribute_description = 'Multiplier 1' then mv.value any other purpose) Multiplier1

    , max (CASE when mv.attribute_description = 'Multiplier 2' then mv.value any other purpose) Multiplier2

    , max (CASE when mv.attribute_description = 'Multiplier 3' then mv.value end to another null) Multiplier3

    from dbo. App APPLICATION, dbo. MY_VALUES mv

    where app.id = mv1.application_id

    and mv.attribute_description IN ('benefits of home', 'multiplier 'multiplier 'multiplier 3' 2' 1')

    and app.id = 1

    This runs often much better than several joins to the table for the view or the value of the attribute.

  • [8i] need help on query with a subquery/inline using UNION ALL view

    OK, first of all let's start with some background info:
    (1) I work in 8i
    (2) some samples for my problem (please excuse the additional columns of data not used to this problem; I already had the sample laying around tables):
    CREATE TABLE     vbom
    (
         part_nbr     char(25)     
    ,     bom_doc_nbr     char(25)     
    ,     bill_level     number          
    ,     comp_part_nbr     char(25)     
    ,     qty_per          number
    );
    --technically has primary and foreign keys, but whatever...
    --part_nbr is your top level (0) parent
    --comp_part_nbr is the specific child
    --bom_doc_nbr is the parent of the child (comp_part_nbr) and may be either part_nbr or a child of part_nbr that is also a parent
    
    INSERT INTO vbom
    VALUES ('SAMPLE-1','SAMPLE-1', 1,'SAMPLE-2',1);
    
    CREATE TABLE     rqmt
    (
         comp_part_nbr     char(25)     
    ,     prnt_part_nbr     char(25)
    ,     ord_nbr          char(10)     
    ,     sub_ord_nbr     char(3)
    ,     qty_reqd     number
    ,     qty_issued     number
    ,     date_reqd     date
    ,     rqmt_stat     char(2)
    ,     rqmt_type     char(2)
    );
    
    INSERT INTO rqmt
    VALUES ('SAMPLE-1','','S0000TEST1',001,30,0,TO_DATE('06/01/2010','mm/dd/yyyy'),'AL','ID');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000054963',001,15,10,TO_DATE('04/01/2010','mm/dd/yyyy'),'CL','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000032562',001,5,5,TO_DATE('04/15/2010','mm/dd/yyyy'),'IS','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000022341',001,5,4,TO_DATE('04/20/2010','mm/dd/yyyy'),'SH','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000043469',001,10,0,TO_DATE('04/30/2010','mm/dd/yyyy'),'AL','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000071235',001,10,0,TO_DATE('05/01/2010','mm/dd/yyyy'),'OP','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000061224',001,5,0,TO_DATE('05/15/2010','mm/dd/yyyy'),'FP','DD');
    INSERT INTO rqmt
    VALUES ('SAMPLE-2','SAMPLE-1','0000033294',001,5,0,TO_DATE('05/25/2010','mm/dd/yyyy'),'PL','DD');
    So, my first question was that I needed to find in the table RQMT who corresponded with everything on my VBOM have vbom.part_nbr table ' SAMPLE-1'. '. (Please note, in reality the VBOM table has thousands of rows of data, rather than just the 1 I have planned, some of them sharing the same vbom.part_nbr, others not). In addition to finding all RQMT data corresponding to the vbom.comp_part_nbr to vbom.part_nbr (where vbom.comp_part_nbr = rqmt.comp_part_nbr), I also need to find RQMT data for vbom.part_nbr itself (then, records where vbom.part_nbr = rqmt.comp_part_nbr).

    To resolve this problem, I started with the following query:
    SELECT     v.bill_level          AS bill_lvl
    ,     v.comp_part_nbr          AS component
    ,     v.bom_doc_nbr          AS parent
    FROM     VBOM v
    WHERE     v.part_nbr     ='SAMPLE-1'
    UNION ALL
    SELECT     0               AS bill_lvl
    ,     'SAMPLE-1'          AS component
    ,     NULL               AS parent
    FROM DUAL
    It allows me to add a line to the top of the page parent (vbom.part_nbr), which does not exist in vbom.
    My first question is, is UNION ALL of the best way to do it, or could I do a kind of instruction based on the line number box (or something) that would be better? (in this application, or in the final query)

    Then, I used the above query as a point of view online:
    SELECT     a.bill_lvl
    ,     a.component
    ,     a.parent
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     (
         SELECT     v.bill_level          AS bill_lvl
         ,     v.comp_part_nbr          AS component
         ,     v.bom_doc_nbr          AS parent
         FROM     VBOM v
         WHERE     v.part_nbr     ='SAMPLE-1'
         UNION ALL
         SELECT     0               AS bill_lvl
         ,     'SAMPLE-1'          AS component
         ,     NULL               AS parent
         FROM DUAL
         ) a
    ,     RQMT r
    WHERE     a.component     = r.comp_part_nbr
    The problem here is that I have the same results (7 files) with the above query as I do with:
    SELECT     v.bill_level
    ,     v.comp_part_nbr
    ,     v.bom_doc_nbr
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     VBOM v
    ,     RQMT r
    WHERE     v.comp_part_nbr     = r.comp_part_nbr
    AND     v.part_nbr     = 'SAMPLE-1'
    .. .it does not include RQMT recording for rqmt.comp_part_nbr = "SAMPLE-1'.

    To understand what was going on, I ran:
    SELECT     a.bill_lvl
    ,     a.component
    ,     a.parent
    FROM     (
         SELECT     v.bill_level          AS bill_lvl
         ,     v.comp_part_nbr          AS component
         ,     v.bom_doc_nbr          AS parent
         FROM     VBOM v
         WHERE     v.part_nbr     ='SAMPLE-1'
         UNION ALL
         SELECT     0               AS bill_lvl
         ,     'SAMPLE-1'          AS component
         ,     NULL               AS parent
         FROM DUAL
         ) a
    .. .and I get exactly this that I wait, 1 card for the SAMPLE-2 component and 1 plug for SAMPLE-1 (i.e. the recording I generated with the UNION ALL).

    Then I ran:
    SELECT     r.comp_part_nbr
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     RQMT r
    WHERE     r.comp_part_nbr like 'SAMPLE-%'
    .. .and I get all 8 records, whose SAMPLE-1.

    So, it seems that the problem occurred when I join my opinion RQMT one online, although both separately seem to work very well.

    A point to note: all parts of parent and child may not be appointed in the same way as in my example. SAMPLE-1 could have children of the SAMPLE-2, abc123, 20735, for example.

    Any help on this would be appreciated, thanks!

    Hello

    Concerns of problem by comparing 8 literal characters ' SAMPLE-1' for the 25-character CHAR column that contains "SAMPLE 1".»
    17 spaces including the literal or use LPAD or CAST to 25 characters.
    For example:

    SELECT     a.bill_lvl
    ,     a.component
    ,     a.parent
    ,     r.ord_nbr
    ,     r.sub_ord_nbr
    ,     r.qty_reqd
    FROM     (
         SELECT     v.bill_level          AS bill_lvl
         ,     v.comp_part_nbr          AS component
         ,     v.bom_doc_nbr          AS parent
         FROM     VBOM v
         WHERE     v.part_nbr     ='SAMPLE-1'
         UNION ALL
         SELECT     0               AS bill_lvl
         ,     CAST ('SAMPLE-1' AS CHAR (25))               -- CAST added here
                                      AS component
         ,     NULL               AS parent
         FROM DUAL
         ) a
    ,     RQMT r
    WHERE     a.component     = r.comp_part_nbr
    ;
    

    Is there a reason why you use CHAR instead of VARCHAR2? (One reason other than "I can't change it now.", otherwise said.)

  • I need help for online with my new laptop mini

    original title: online

    I bought a laptop mini JC Penny, which is supported by micrsoft 5.0, everyone don't know how I can get online?

    Hi LEEHill H,

    What is the manufacturer, brand and full model number and of the notelbook (I want to look it up online to see if there are instructions available)?  If you do not have this information, what is the reference number of JC Penny?  It come with an ISP account or you plan to use your?  How do you intend to connect to the internet (wireless via a router, cable, wireless by satellite link,...)?  If you want to install it anywhere (which means a satellite connection), your current ISP is perhaps not able to manage and you may need a separate account for this.

    The laptop come with instructions - or links to the online instructions?

    If XP is used for network access, then the installer should be easy once we understand how your ISP account is set up and how to access the functions of network configuration (if this is not the full product, but only parts of it).  Answers to the questions above should help us determine how to proceed (I hope).

    Thanks and good luck!

  • Need help for the particular case of selection

    Oracle DB 12 c, I think than 12.1.2

    drop table person_tests;

    create table person_tests)

    person_id number,

    test_type_id varchar2 (1).

    date of test_date

    );

    insert into person_tests (person_id, test_type_id, test_date) values (1, 'A', to_date('01012000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (1, 'A', to_date('01022000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (1, 'B', to_date('01032000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (1, 'B', to_date('01042000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (1,', to_date('01052000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (2,', to_date('01062000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (3, 'A', to_date('01072001','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (3, 'A', to_date('01082000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (3, 'B', to_date('01092000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (3, 'B', to_date('01102000','MMDDYYYY'));

    insert into person_tests (person_id, test_type_id, test_date) values (3,', to_date('01102000','MMDDYYYY'));

    People as a participant in some of the tests: A, B and C where each event is tagged with a date when finished.

    I need to get out of the only people who have done 2 tests of type A, 2 type tests B and 1 type C. I test have show the type of test and the date of the most recent of these tests. In the above example would output desired

    1 JANUARY 5 C 00

    3. A 7 JANUARY 01

    Hope that this definition of the logical problem

    Hello

    Sorry, I missed the obligation to show the most recent test_type_id.

    Assuming that the date to display is the date, that the minimum conditions were met (if not gratutitous trials came afterwrds), you can do something like this:

    WITH got_r_num AS

    (

    SELECT person_id, test_type_id, test_date

    , ROW_NUMBER () OVER (PARTITION BY person_id, test_type_id)

    ORDER BY test_date

    ) AS r_num

    OF person_tests

    WHERE test_type_id IN ('A', 'B', 'C')

    )

    SELECT person_id

    MIN (test_type_id) DUNGEON (DENSE_RANK LAST ORDER BY test_date) AS last_test_type

    MAX (test_date) AS last_test_date

    OF got_r_num

    WHERE r_num<= case ="">

    WHEN 'A' THEN 2

    WHEN 'B' THEN 2

    WHEN 'C' THEN 1

    END

    GROUP BY person_id

    HAVING COUNT (*) = 5-2 ' A + 2 ' B + 1 'C '.

    ;

    What test_type_id would you like to display tie for the final round?

    I just saw your post by saying that a person with 3 or more 'A' type tests should be excluded.  In this case, my original solution (with = in the WHERE clause) is what you want; only FINALLY used to get past test_type_id.  The solution in this post is for the situation where you don't care if there are 3 or more ' has, but you want to ignore all but the first 2.

  • need help for query, accumulative sum

    We have a room with two doors, one of which is installed with biometric devices

    so total devices are 4-two IN and two out

    a table we where these enteries are saved:

    name, record type, id,

    a, 1, June 4, 2015 09:00:13 ', '1 - IN'

    "a, 1, June 4, 2015 09:10:13 ', ' 1 - OUT"

    a, 1, June 4, 2015 09:30:13 ', '2 - IN'

    "a, 1, June 4, 2015 11:00:13 ', ' 1 - OUT"

    create table DRC (varchar2 (40) name, identification number, registration timestamp, type varchar2 (10));

    insert into rec values ('a', 1, June 4, 2015 09:00:13 ', '1 - IN');

    insert into rec values ('a', 1, 4 June 2015 09:10:13 ', ' 1 - OUT');

    insert into rec values ('a', 1, June 4, 2015 09:30:13 ', '2 - IN');

    insert into rec values ('a', 1, 4 June 2015 11:00:13 ', ' 1 - OUT');

    I am designing the query result as below:

    power required

    identification, intype intimate outtime outtype

    a, 1, 04/06/2015-09:00:13 1 - IN 04/06/2015-09:10:13 1-OUT

    a, 1, 04/06/2015-09:30:13 IN. 2-04/06/2015 11:00:13 1-OUT

    Displaying data with name = 'b' (adjusted for hh24) added that he does not understand the OP

    with

    REC as

    (select 'a' name, 1 id, the to_date (June 4, 2015 09:00:13 ',' dd-mm-yyyy hh24:mi:ss') (timestamp,"1-IN' type of union double all the)

    Select 'a', 1, to_date (June 4, 2015 09:10:13 ',' dd-mm-yyyy hh24:mi:ss'), '1 - OUT' of all the double union

    Select 'a', 1, to_date (June 4, 2015 09:30:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - IN' of all the double union

    Select 'a', 1, to_date (June 4, 2015 11:00:13 ',' dd-mm-yyyy hh24:mi:ss'), '1 - OUT' of all the double union

    Select 'b', 2, to_date (June 4, 2015 11:30:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - IN' of all the double union

    Select 'b', 2, to_date (June 4, 2015 14:00:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - OUT' Union double all the

    Select 'b', 2, to_date (June 4, 2015 14:30:13 ',' dd-mm-yyyy hh24:mi:ss'), '2 - IN' of all the double union

    Select 'b', 2, to_date (June 4, 2015 18:00:13 ',' dd-mm-yyyy hh24:mi:ss'),'1 - OUT "of the double

    )

    SELECT name, id, to_char (timestamp, 'dd-mm-yyyy hh24:mi:ss') in_time, typ in_type, to_char (outtime, 'dd-mm-yyyy hh24:mi:ss') out_time, outtype out_type

    (select name, id, timestamp, type,

    cases where instr(typ,'IN') > 0 then lead (timestamp) on the end (partition by name, by order of the identification by timestamp) outtime.

    cases where instr(typ,'IN') > 0 then lead (typ) on the end (partition by name, by order of the identification by timestamp) outtype

    REC

    )

    where coalesce (to_char (outtime, 'yyyymmddhh24miss'), outtype) is not null

    order by name, id, in_time

    NAME ID IN_TIME IN_TYPE OUT_TIME OUT_TYPE
    one 1 04/06/2015-09:00:13 1. 04/06/2015-09:10:13 1-OUT
    one 1 09:30:13 04/06/2015 2. IN 04/06/2015 11:00:13 1-OUT
    b 2 04/06/2015 11:30:13 2. IN 04/06/2015 14:00:13 2 OUTPUTS
    b 2 14:30:13 04/06/2015 2. IN 04/06/2015-18:00:13 1-OUT
  • need help for query

    Hello

    I have a table produced, have two columns and below the sample data and I want to select distinct values in this table on the two columns. Please let me know how can achieve us.

    x                                                                y

    ===                                                       ===

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 6

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion Essentials ~ 2

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 6

    Lithion ~ Tmobile Lithion Lithion ~ Tmobile Lithion ~ 6

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 7

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 8

    output:

    =====

    x                                                                y

    Sony Erricson ~ Lithion Sony Erricson ~ Lithion ~ 6

    Lithion ~ Tmobile Sony Erricson Lithion ~ Lithion Essentials ~ 2

    NULL the Sony Erricson ~ Lithion ~ 7

    NULL the Sony Erricson ~ Lithion ~ 8

    Help is very appreciated.

    THX in advance

    one of the ways below, if this does not help please share create table statement and the data from the sample as insert the script with desired output

    with data
    as
    (
    select 'Sony Erricson~Lithion' prd1,'Sony Erricson~Lithion~6' sub_prd from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion Essentials~2'  from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion~6'  from dual
    union all
    select 'Lithion~Tmobile Lithion','Lithion~Tmobile Lithion~6' from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion~7' from dual
    union all
    select 'Sony Erricson~Lithion','Sony Erricson~Lithion~8' from dual
    )
    select case when rn > 1 then null else prd1 end prd1,
    sub_prd,
    rn2
    from (
    select prd1, sub_prd, row_number() over(partition by prd1 order by prd1) rn,
    row_number() over(partition by prd1,sub_prd order by prd1,sub_prd) rn2 from data
    )
    where rn2 = 1
    order by prd1
    
  • Need help for optical safety circuit.

    I buy these parts and prototype with real components, but since I multisim, I thought it would be nice to create the circuit and maybe work through issues I can practically.

    I need a circuit that takes 120 VCA, generates 5 VDC and 1.5Vdc power of optical transmitter and receiver.  I actually use a data port because he has great range and is pretty cheap.  Rather than send the binary code well I just send a light stead that is broken or not broken through doors and windows in my house.  Then the receiver sees this as an entry and order a relay.

    I tried several voltage regulators that come with multisim, but I get an error of execution of my circuit.  Really I can't the 120 VAC to power levels necessary for the functioning of the optics.

    Otherwise I might want to run on a system 120Vdc with battery backup, so throw a 120Vdc up to 20 v DC switching power supply - but I have not found a SMP in the library which takes 120 as input and as output 20.

    Basic plan: 120VAC source-> transform to 24Vac-> Full bridge rectifier to ~ 20 v DC-> voltage capacitor filter on the input of two voltage regulators (1 to 5 VDC, 1 to 1.5Vdc) - then circuit since the two power supply of the transmitter and the receiver.

    I just need help for 5V and 1.5V, from there, I know that the real world circuit will work component tests already carried out.  Thanks for reading.

    I didn't Multism so I can't advise you on the compatible models. I ran the model on semiconductors with slight modifications of format on my SPICE simulator based on Berkeley Spice 3f5. I had to change the format of model resistance semiconductors appeal but has not changed any values.

    The output of your power supply circuit 3 (with 5 V, not the 1.5 V regulator regulator) was 4.99995 V.

    There are a few messages about changing templates published for compatibility Multisim woth. You can search those to see if there are any suggestions on what you'll need to fix in the model.

    Lynn

  • I need help for the upgrade of my current system.

    I need help for the upgrade of my current system.

    I have SBS 2008 with (Exch 2007, SQL 2005, Sharepoint, backupexec 2010 for sbs) licenses.

    I want to make the larger environment using the following:

    (1) apply Virtualization

    (2) apply to the failover process (clustering)

    "(3) the environment must support adding server terminal server, ERP server, exchange server, domain controller, backup manager.

    Storage 4) that supports Raid (1 and 5)

    UTM excellent 6) that supports (SSL VPN, VPN Global)

    suitable backup solution 7)

    (8) good antivirus for clients

    my questions:

    (1) can you provide me with a good design for this environment

    (2) should I choose what operating system:

    Microsoft datacenter or company

    I know datacenter provide us the unlimited VM but needs per processor license

    so if I have two Grouped servers I want to buy 4 licenses

    and just 4 VMs per company license... to say that we have two servers and maintain 8 vms so wat happened if 1 goes down... How can I migrate the 4 virtual machines on the server failed to another server group... ? should I buy enterprise license?

    (3) if I get the SAN storage for data... How can I save this storage... should I get another SAN?

    (4) how can I upgrade SBS stad single server (windows standrad) without losing the licenses as Exch 2007, SQL 2005, sharepoint.is it a must to buy an edition full std server or there is a way to upgrade (license wise, I mean)?

    (5) what about win2k8 license for VM:

    lets say we have physical that has windows license so that enough to have windows for VM or should I buy windows for VM licenses?

    (6) can I use backExec license for SBS with windows 2008 standard

    (7) who better to virtualization AMD or INTEL

    (8) hyper V or VMware?

    (9) what of Microsoft data protection Manager... is this good?

    (10) what virtual machine manager? What are the benefites keys

    Thanks in advance

    Hello AnasAI,

    You can find the Server forums on TechNet support, please create a new post at the following link:

    http://social.technet.Microsoft.com/forums/en/category/WindowsServer/

  • I need help for activation of the real administrator account.

    I have a problem with Adobe reader 9 standard, Adobe customer service asked the unhide real administrator account before you can continue to help me.

    I need help for that.

    http://www.Vistax64.com/tutorials/67567-administrator-account.html

    http://www.howtogeek.com/HOWTO/Windows-Vista/enable-the-hidden-administrator-account-on-Windows-Vista/

    Read the above info.

    See you soon. Mick Murphy - Microsoft partner

  • I need help for my reader to USB drive on my windows 10 ACER?

    I need help for my reader to USB stick on my chrome windows 10 plug ins acer. Can you help me?

    What Adobe application that you use?

    This is the Adobe Media Encoder forum, and you did not mention anything on this subject. If you can let us know what Adobe application, you need help, we can help you make the right forum.

    Thank you

    Regalo

  • Hello, I need help for cancel the payment on my adobe account.

    Hello, I need help for cancel the payment on my adobe account. I'm from Peru, Im paying a monthly fee as a student. Help, please...

    Cancel your membership creative cloud

Maybe you are looking for

  • Qosmio F60 and Windows XP

    Hello I need to know if I can delete win 7 and install Windows XP on my Qosmio F60I am a student online and the software is not compatible with win 7 and IE8I need at least of the video, network and WIFI win XP drivers ASAP Thank you very muchAmedeo.

  • NB - how to activate the multi gesture?

    Hello world. When I unboxed the laptop and turn it on the first time, multi gestures functionality worked well... Although I can turns off this feature because no longer works. How can I enable this feature again? Cheers!

  • Camileo H20 stopped zoom

    Hi allFirst time post here. I have a camcorder Camileo H20 HD, I used it very well throughout the week, but just tonight, when I tried filming something just zoom on top button does – whatever way she moves, nothing appears on the screen and the imag

  • X 1 display carbon 2014

    I have the all-new X 1 carbon with WQHD display. I wiped the drive and installed Ubuntu Linux 13.10. Everything works perfectly. Sound, WiFi, camera, trackpad... everything works fine without any problems. I also have a new T540p running Windows 8.1.

  • The 'IETF-RADIUS-Idle-Timeout' value substitute "Vpn-session-timeout' of group policy?

    Hello community, I wish to have a dynamic substitution of "Vpn-session-timeout' of Group Policy (using"ldap attribute-map"). Read the section "Support for RADIUS authorization attributes" of the SAA, it is not clear, but apparently attribute 'IETF-RA