Need an accurate or appropriate SQL for the mentioned release

People,

Find the sample data with the query.

1.

with aa(id1)
as
(
select 1 from dual union all
select 2 from dual union all
select 3 from dual union all
select 4 from dual union all
select 5 from dual union all
select 6 from dual union all
select 7 from dual union all
select 8 from dual union all
select 9 from dual)
,
bb (id2)
as
(
select 1 from dual union all
select 2 from dual union all
select 3 from dual
)
select  id1, nvl(id2, id1 -  count(id2) over(Order by null)) id2
from aa full join bb on id1=id2;

Actual output: -.

ID1 ID2

----------

1 1

2 2

3 3

4 1

5 2

6 3

4 of 7

8 5

9 6

Expected results: -.

ID1 ID2

----------

1 1

2 2

3 3

4 1

5 2

6 3

1 of 7

8 2

9 3

NB:-1,2,3 must be repeated with the increase of the data in the table aa. I don't get an exact hit on top of the query point, it can be simple or maybe not! So let me know soon & quick and simple solution must be assessed.

Thank you!

This way:

with aa (id1)

as

(

Select 1 in all the double union

Select 2 Union double all the

Select 3 in all the double union

Select option 4 Union double all the

Select 5 Union double all the

Select 6 Union double all the

Select 7 Union double all the

Select 8 Union double all the

Select 9 double)

,

BB (id2)

as

(

Select 1 in all the double union

Select 2 Union double all the

Select 3 double

)

Select id1, decode (mod (row_number () (any order by id1), (select max (id2) in bb)), 0, (select max (id2) of bb), mod (row_number () (any order by id1), (select max (id2) in bb))) id_2

AA;

Tags: Database

Similar Questions

  • I need to scan my macbook pro for the virus. any medium online Apple?

    I need to scan my macbook pro for the virus. any medium online Apple?

    Viruses are made for Windows computers.  Macs are less vulnerable to viruses. Why do you think your Mac virus?

    http://www.reedcorner.NET/MMG/

    http://www.thexlab.com/FAQs/malspyware.html

    Mac quarantine folder: about the alert "do you want to open it? (file quarantine / known malicious code detection) in OS X - Apple support

  • I want to know if I need to install Vista on it for the purchase of a Windows 7 upgrade edition?

    Editions of Windows upgrade

    Hey guys, I have a Windows Vista free disk and I'm building a new pc. I plan Windows 7 Pro, but I want to know if I need to install Vista on it for the purchase of a Windows 7 upgrade edition, or can I use the product key that came with Vista, when you install the updated version?

    In order to use the versions of Windows 7 upgrade, you must have a previous qualification license installed (Vista or XP), Windows 7 upgrade must be a compliance check. There is no need to activate it if.

  • I downloaded Lightroom 6 thanks to Amazon and never received an email from Adobe with the serial number, I need to finish my license/registration for the product...where/how can I get the serial number?

    I downloaded Lightroom 6 thanks to Amazon and never received an email from Adobe with the serial number, I need to finish my license/registration for the product...where/how can I get the serial number?

    Hello dakineny,

    Please refer to the link given to find your serial number: quickly find your serial number

    It will be useful.

    Concerning

    Bianka Attre

  • Need me a new case number for the license transfer form? I'm the beneficiary of a transfer of li

    Need me a new case number for the license transfer form? I'm the beneficiary of a transfer of license product registration. The person transferring has already completed and returned the transfer of license form. Can I use the same number, or do I need a new number.

    You have to get a new number for you because the transferor and the recipient cannot use the same number.

    Reference: I talked to an officer of Adobe, and this was the answer they gave me.

  • Could not find an appropriate interface for the private interconnection range

    I'm going to install RAC 11.2.0.2 on two nodes REDHAT linux.

    I ran runcluvfy pre crsinst, he gave me warning as follows:
    Could not find an appropriate interface for the private interconnection range.

    I asked her to use a different subnet as public interconnection for interconnecting private as well as the name / etc/hosts also set private ip addresses. Private ip address is not defined in the DNS system.

    .runInstaller also not will pop up the Ethernet because private interconnection over choice of network.

    What to do to solve this problem?

    Thanks in advance.

    You can temporarily change the mask of 255.255.255.0 on eth3 and see if YES recognizes eth3?

  • SQL for the webADI fields

    Hello

    I need a SQL to retrieve the fields and another piece of land to show if it is a line or a header for the WebADI project.

    Can someone provide me with this SQL if you have already worked on it?

    Thank you and best regards,

    Yuvraj

    SELECT DISTINCT fap.application_short_name 'Application Short Name',

    bib.User_Name "integrating user name."

    BLB.user_name "name of the page layout."

    bicb.interface_col_name "name of the field."

    blbb.user_name 'investment. "

    BLC. Default_value 'Default Value ',.

    UPPER CASE (NVL (blc.default_type, 'NONE'))

    WHEN 'NONE', THEN 'none'

    WHEN "FORMULA", THEN "Formula".

    WHEN 'CONSTANT' THEN 'constant '.

    WHEN 'PARAMETER' THEN 'setting '.

    WHEN 'SQL' THEN 'SQL '.

    WHEN 'ENVIRONMENT' THEN 'environment '.

    ANOTHER "UNKNOWN".

    END

    'The Type by default'

    OF apps.fnd_application fap.

    Apps.bne_integrators_vl bib,

    Apps.bne_layouts_vl blb,

    Apps.bne_layout_blocks_tl Boop,

    Apps.bne_layout_cols blc,

    Apps.bne_interface_cols_b bicb,

    Apps.bne_components_b bcb,

    Apps.bne_param_lists_b bplb,

    Apps.bne_param_list_items bpli

    WHERE 1 = 1

    AND fap.application_id = bib.application_id

    -bne_integrators_b | bne_layouts_b

    AND bib.integrator_code = blb.integrator_code

    AND bib.application_id = blb.integrator_app_id

    -bne_layouts_b | bne_layout_blocks_b

    AND blb.layout_code = blbb.layout_code

    AND blb.application_id = blbb.application_id

    -bne_layout_blocks_b | bne_layout_cols

    AND blbb.layout_code = blc.layout_code

    AND blbb.application_id = blc.application_id

    AND blbb.block_id = blc.block_id

    -bne_layout_cols | bne_interface_cols_b

    AND blc.application_id = bicb.application_id

    AND blc.interface_code = bicb.interface_code

    AND blc.sequence_num = bicb.sequence_num

    -bne_interface_cols_b | bne_components_b

    AND bicb.application_id = bcb.application_id

    AND bicb.val_component_code = bcb.component_code

    -bne_components_b | bne_param_lists_b

    AND bcb.param_list_code = bplb.param_list_code

    -bne_param_lists_b | bne_param_list_items

    AND bplb.param_list_code = bpli.param_list_code

    AND blbb.language = 'en '.

    AND fap.application_short_name = 'PA '.

    ORDER BY 1, 2;

  • Need help with a query complex for the production database

    Hello again,

    I need your help once again, for a query how to show me how long each stage of production is by order.
    See examples of data and what I expect.
    Thank you all for your help.

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

    Here the example data tables:
    CREATE      TABLE      TABLE_2
       
    (     "ORDER_NR"      VARCHAR2 (12)
    ,      "PRIORITY"      VARCHAR2 (2)
    ,      "WO_STEP"      VARCHAR2 (1)
    ,      "STEP_DATE"      DATE
    );
    
    CREATE      TABLE      TABLE_1
    (     "ORDER_NR"           VARCHAR2     (12) PRIMARY KEY
    ,      "PRIORITY"           VARCHAR2      (2)
    ,      "CREATE_DATE"      DATE
    ,     "ACT_STEP"          VARCHAR2     (2)
    ,     "STEP_DATE"          DATE
    ,     "EMPLOYEE"          VARCHAR2     (5)
    ,     "DESCRIPTION"     VARCHAR2     (20)
    );
    
    INSERT      INTO      TABLE_1      (ORDER_NR,               PRIORITY,      CREATE_DATE,                                                        ACT_STEP,     STEP_DATE,                                                            EMPLOYEE,     DESCRIPTION) 
                        VALUES           ('1KKA1T205634',     '12',          TO_DATE('10-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS'),     'U',          TO_DATE('28-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS'),     'W0010',     'CLEAN HOUSE');
    INSERT      INTO      TABLE_1      (ORDER_NR,               PRIORITY,     CREATE_DATE,                                                        ACT_STEP,     STEP_DATE,                                                            EMPLOYEE,     DESCRIPTION)
                        VALUES           ('1KKA1Z300612',     '12',          TO_DATE('08-FEB-13 14:00:00','DD-MON-RR HH24:MI:SS'),     'F',          TO_DATE('20-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS'),     'K0052',     'REPAIR CAR');
    
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'A',          TO_DATE('12-FEB-13 13:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          '5',          TO_DATE('13-FEB-13 09:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'K',          TO_DATE('13-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          '5',          TO_DATE('13-FEB-13 11:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'K',          TO_DATE('13-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          '5',          TO_DATE('13-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'C',          TO_DATE('14-FEB-13 08:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'B',          TO_DATE('14-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'E',          TO_DATE('18-FEB-13 13:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'F',          TO_DATE('20-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'S',          TO_DATE('21-FEB-13 08:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'R',          TO_DATE('21-FEB-13 09:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1T205634',     '12',          'U',          TO_DATE('28-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'A',          TO_DATE('12-FEB-13 13:52:42','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          '5',          TO_DATE('13-FEB-13 09:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'K',          TO_DATE('13-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          '5',          TO_DATE('13-FEB-13 11:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'K',          TO_DATE('13-FEB-13 12:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          '5',          TO_DATE('13-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'C',          TO_DATE('14-FEB-13 08:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'B',          TO_DATE('14-FEB-13 10:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'E',          TO_DATE('18-FEB-13 13:00:00','DD-MON-RR HH24:MI:SS'));
    INSERT     INTO      TABLE_2      (ORDER_NR,               PRIORITY,     WO_STEP,     STEP_DATE)
                        VALUES           ('1KKA1Z300612',     '12',          'F',          TO_DATE('20-FEB-13 16:00:00','DD-MON-RR HH24:MI:SS'));
    COMMIT;
    And here's what I expect of my request:
    SYSDATE     28.Feb.13 14:00                                                                                     
                                                                                              
    ORDER_NR     PRIORITYCREATE_DATE     STATUS     STATUS_DATE     DESCRIPTION     AGE_1     AGE_2     WAITNG     STEP_A     STEP_B     STEP_C     STEP_5     STEP_K     STEP_E     STEP_F     STEP_S     STEP_R     
    1KKA1T205634     12     10.Feb.13 10:00     U     28.Feb.13 12:00     CLEAN HOUSE     18,083     8,833     2,125     0,833     4,125     0,083     0,750     0,208     2,125     0,666     0,042     7,125     
    1KKA1Z300612     12     08.Feb.13 14:00     F     20.Feb.13 16:00     REPAIR CAR     20,000     16,042     2,125     0,833     4,125     0,083     0,750     0,208     2,125     0,666          
    And now the explanation for the result of the query:
    The AGE_1 is the difference in days between the "CREATE_DATE" and if EXSIST L'ETAPE 'U' then STEP_DATE or if the STEP 'U' is not found in TABLE_2 then it should show the difference in days between the "CREATE_DATE' and the 'SYSDATE.
    The AGE_2 is the difference in days between the STEP "A" STEP_DATE and IF EXSIST L'ETAPE 'R' then STEP_DATE or if the STEP 'R' is not in TABLE_2 then it should show the difference in days between the "CREATE_DATE' and the 'SYSDATE.
    The EXPECTATION is the difference in days between CREATE_DATE and STEP 'A' STEP_DATE
    The following columns indicate the days, how long the ORDER_NR remains in these TIMES, if an ORDER_NR comes in the same STEP should be calculated together more than once.
    If the ORDER_NR jump a step, it should show a zero in the specific field.

    I hope that my explanation is good enough, my English skills are far from good.

    Thank you for all your help.

    Hosts Reinhard W.

    Solomon Yakobson says:
    Just add the amounts:

    In fact, you could edit all CASES:

    with t2 as (
                select  t.*,
                        lead(step_date) over(partition by order_nr order by step_date) next_step_date
                  from  table_2 t
               )
    select  t1.*,
            nvl(
                max(
                    case t2.wo_step
                      when 'U' then t2.step_date
                    end
                   ),
               sysdate
              ) - t1.create_date age_1,
            nvl(
                max(
                    case t2.wo_step
                      when 'R' then t2.step_date
                    end
                   ),
               sysdate
              ) - t1.create_date age_2,
            sum(
                case
                  when t2.wo_step in ('B','5') then t2.next_step_date - t2.step_date
                end
               ) step_b_5,
            sum(
                case t2.wo_step
                  when 'C' then t2.next_step_date - t2.step_date
                end
               ) step_c,
            sum(
                case t2.wo_step
                  when 'K' then t2.next_step_date - t2.step_date
                end
               ) step_k,
            sum(
                case t2.wo_step
                  when 'E' then t2.next_step_date - t2.step_date
                end
               ) step_e,
            sum(
                case t2.wo_step
                  when 'F' then t2.next_step_date - t2.step_date
                end
               ) step_f,
            sum(
                case t2.wo_step
                  when 'S' then t2.next_step_date - t2.step_date
                end
               ) step_s,
            sum(
                case t2.wo_step
                  when 'R' then t2.next_step_date - t2.step_date
                end
               ) step_r
      from  table_1 t1,
            t2
      where t2.order_nr = t1.order_nr
      group by t1.order_nr,
               t1.priority,
               t1.create_date,
               t1.act_step,
               t1.step_date,
               t1.employee,
               t1.description
    /
    
    ORDER_NR     PR CREATE_DA AC STEP_DATE EMPLO DESCRIPTION      AGE_1      AGE_2   STEP_B_5     STEP_C  STEP_K     STEP_E     STEP_F        STEP_S     STEP_R
    ------------ -- --------- -- --------- ----- ----------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
    1KKA1T205634 12 10-FEB-13 U  28-FEB-13 W0010 CLEAN HOUSE 18.0833333 10.9583333      4.875 .083333333 .208333333      2.125 .666666667 .041666667      7.125
    1KKA1Z300612 12 08-FEB-13 F  20-FEB-13 K0052 REPAIR CAR   44.252338  44.252338      4.875 .083333333 .208333333      2.125
    
    SQL>
    

    SY.

  • How the group using SQL for the desired output.

    Hi all

    I am currently using oracle 10.2.0.4.0

    Create a table script:
    CREATE TABLE FORTEST
    ( gpno VARCHAR2(10 BYTE),
      classnumber  VARCHAR2(10 byte),
      age_min NUMBER,
      age_max NUMBER,
      amount NUMBER)
    INSERT statement:
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,0,29,1) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,30,35,2) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,36,40,3) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,0,29,1) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,30,35,2) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,36,40,5) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,0,29,1) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,30,35,2) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,36,40,3) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,0,29,1) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,30,35,2) 
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,36,40,3) 
    power required:
    gpno    classnumber    age_min    age_max    amount
    G123    1,3                0        29        1
    G123    1,3                30       35        2
    G123    1,3                36       40        3
    G123    2                  0        29        1
    G123    2                  30       35        2
    G123    2                  36       40        5
    G124    1                  0        29        1
    G124    1                  30       35        2
    G124    1                  36       40        3
    as for gpno g123, classnumber 1 and 3, the rates are the same in all the age_min and age_max they need to be grouped.
    even if gpno 123 classnumber 2 has the same rates as the classesnumber 1 and 3 for the age groups 0 to 29 and 30 to 35,
    rates are different for ages 36 to 40. so it should not be placed together. How can I do this in SQL

    any help is appreciated.

    Thanks in advance.

    Hello

    Thorny problem!

    Unfortunately, LISTAGG was created to the Oracle 11.2. About half of the complexity here is the aggregation of chain, i.e. forming the list of the classnumbers, as '1.3', using only functions available in Oracle 10.2.

    Here's a solution:

    WITH     got_gpno_classnumber_cnt   AS
    (
         SELECT     gpno, classnumber, age_min, age_max, amount
         ,     COUNT (*) OVER ( PARTITION BY  gpno
                                      ,            classnumber
                          )   AS gpno_classnumber_cnt
         FROM    fortest
    --     WHERE     ...     -- If you need any filtering, this is where it goes
    )
    ,     pairs          AS
    (
         SELECT    a.gpno
         ,       a.classnumber
         ,       MIN (b.classnumber)
                    OVER ( PARTITION BY  a.gpno
                              ,                    a.classnumber
                      )     AS super_classnumber
         FROM       got_gpno_classnumber_cnt  a
         JOIN       got_gpno_classnumber_cnt  b  ON   a.gpno     = b.gpno
                                      AND  a.age_min     = b.age_min
                                    AND  a.age_max     = b.age_max
                                    AND  a.amount     = b.amount
                                    AND  a.gpno_classnumber_cnt
                                            = b.gpno_classnumber_cnt
         GROUP BY  a.gpno
         ,            a.classnumber
         ,       b.classnumber
         HAVING       COUNT (*)     = MIN (a.gpno_classnumber_cnt)
    )
    ,     got_rnk          AS
    (
         SELECT DISTINCT
                 gpno, classnumber, super_classnumber
         ,     DENSE_RANK () OVER ( PARTITION BY  gpno
                                   ,                    super_classnumber
                                   ORDER BY          classnumber
                           )         AS rnk
         FROM    pairs
    )
    ,     got_classnumbers     AS
    (
         SELECT     gpno, classnumber, super_classnumber
         ,      SUBSTR ( SYS_CONNECT_BY_PATH (classnumber, ',')
                       , 2
                     )     AS classnumbers
         FROM     got_rnk
         WHERE     CONNECT_BY_ISLEAF = 1
         START WITH     rnk             = 1
         CONNECT BY     rnk             = PRIOR rnk + 1
              AND     gpno             = PRIOR gpno
              AND     super_classnumber  = PRIOR super_classnumber
    )
    SELECT DISTINCT
           g.gpno
    ,       c.classnumbers
    ,       g.age_min
    ,       g.age_max
    ,       g.amount
    FROM       got_gpno_classnumber_cnt  g
    JOIN       got_classnumbers         c  ON   c.gpno        = g.gpno
                                 AND  c.classnumber  = g.classnumber
    ORDER BY  g.gpno
    ,            c.classnumbers
    ;
    

    Out (just as you requested):

    GPNO       CLASSNUMBERS       AGE_MIN    AGE_MAX     AMOUNT
    ---------- --------------- ---------- ---------- ----------
    G123       1,3                      0         29          1
    G123       1,3                     30         35          2
    G123       1,3                     36         40          3
    G123       2                        0         29          1
    G123       2                       30         35          2
    G123       2                       36         40          5
    G124       1                        0         29          1
    G124       1                       30         35          2
    G124       1                       36         40          3
    
  • Help: SQL for the massive update (service lead)

    Hello

    I use Oracle11.2. I want to update the column of hist_dttm of tb_hist with the tb_base crt_dttm column value in the following line, which is ordered by crt_dttm. Here are the details:

    creat table tb_base (tid varchar2 (32), crt_dttm timestamp (6));
    creat table tb_hist (tid varchar2 (32), crt_dttm timestamp (6), upd_dttm timestamp (6));

    insert into tb_base values ("AAA", to_timestamp (12 January 05 14:00:00.123456', ' dd-mm-rr hh24:mi:ss.ff'));))
    insert into tb_base values ("AAA", to_timestamp (May 12 05 14:00:00.123456', ' dd-mm-rr hh24:mi:ss.ff'));))
    insert into tb_base values ("AAA", to_timestamp (16 December 05 14:00:00.123456', ' dd-mm-rr hh24:mi:ss.ff'));))

    insert into tb_base values ("AAA", to_timestamp (12 January 05 14:00:00.123456', 'dd-mm-rr hh24:mi:ss.ff'), null);
    insert into tb_base values ("AAA", to_timestamp (May 12 05 14:00:00.123456', 'dd-mm-rr hh24:mi:ss.ff'), null);

    I use the following SQL to update the column upd_dttm of the tb_hist, I'm waiting for the upd_dttm needs to be updated to "12/05/05 14:00:00.123456 ' and 14:00:00.123456 16 December 05. However they is NULL. Any suggestion?



    Update tb_hist hist
    Set (upd_dttm) = (select lead (base. CRT_DTTM over (Partition by order of base.tid of base.crt_dttm)
    tb_base base
    where base.tid = hist.tid
    and base.crt_dttm = hist.crt_dttm)
    ;
     update tb_hist
      set crt_dttm= (select min (crt_dttm)
           from tb_base
         where tb_base.crt_dttm > tb_hist.crt_dttm)
    

    Published by: DPT Opitz Consulting com on 09.10.2012 19:24

    Published by: DPT Opitz Consulting com on 09.10.2012 19:25

  • SQL for the synchronous question of AIR vs. asynchronous

    Gidday guys

    I've implemented a SQLite database that will be processing up to 150 000 lines at the same time.  I use parametized queries, wrapped in a transaction, it should be fast enough. I use asynchronous methods.

    I put the motions and managed to get a static test of query in the database using the parameters.  Wahooo!

    However, now I did it dynamic to receive bulk data, I get the error:

    "Operation could not be performed SQLStatement.executing is true.

    I wonder if anyone can

    (a) suggest that synchronous may be a better option

    or

    (b) guide me as to what order the functions and event listeners would fix my follows established...

    THE PROCESS:

    -J' have a lot of file names in an array, that need to be tweaked before thrown into the database

    -J' set up the sql (leg work done earlier) connection, the query statement, and then start a transaction:

    insertStmt.sqlConnection = conn;

    insertStmt.text = "INSERT or IGNORE INTO tester3 VALUES (@col1, @col2);

    Conn.Begin ();

    -table is thrown into a function that starts an enterFrame iteration (if the display does not freeze), where I change the names of files, and put each file name twisted and other (also directed for the database) data in an object and deliver it to the function that prepares the data in the settings...

    prepareParameters ({col1:col1var, col2:col2var});})

    prepareParameters(row:Object):void

    {

    [insertStmt.parameters["@col1"] = row.col1;

    [insertStmt.parameters["@col2"] = row.col2;

    insertStmt.execute ();
    }

    -at the end of the loop table, call the transaction end function

    I think the problem is that the loop sends the next object to prepareParameters() until the database has finished executing the last insert statement.

    I tried to configure a listener for results to try to make Flash do not return to the loop until the listener received something, but I get the same error.

    My first thought was "Hey, shouldn't Flash wait until after insertStmt.execute ();" has finished before returning to the loop that calls its function? But maybe this happens in synchronous treatment?

    Thanks for your thoughts guys.

    Before I head to a few races a couple quick notes.

    If you just want a quick number of items affected in the database across all executions altogether (although SQLConnection is maintained), you can use this property:

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/data/SQLConnectio #totalChanges n.html

    To be more practical, SQLResult can be used on a SQLStatement instance after it is over (after the RESULT event). If you do not want to use it (as in the example above) in the manager function, _runQuery. The SQLEvent sent to method (apart from the first _runQuery (null)) will contain a reference to the SQLStatement instance that has been run. You can see me access it explicitly to remove the handler from the success of it as follows:

    If (e)

    {

    SQLStatement (e.taget) .removeEventListener (SQLEvent.RESULT, _runQuery);

    }

    Which is simply check to see if I have a valid (non-null) event sent to the method and if yes I use it to remove the handler. I could use a weak reference in the event handler, but on devices, I would be extremely explicit in removing all memory that I absolutely is useless as soon as possible.

    That said, each SQLStatement has getResult() method:

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/data/SQLStatement .html #getResult ()

    That method contains the method, you asked:

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/data/SQLResult.ht ml #rowsAffected

    It's just the number of rows affected by your last statement (UPDATE, INSERT, DELETE,...). If you want to follow him through multiple SQLinstructions you could do a new class var to collect the results, if you do not use SQLConnection totalChanges I linked above:

    If (e)

    {

    get an official reference

    var insertStmt:SQLStatement = (e.target) SQLStatement;

    results of this execution

    var result: SQLResult = insertStmt.getResult ();

    draw some properties of an "INSERT" as you do

    trace ("Insert ID:" + result.lastInsertRowID + ", affected rows:" + result.rowsAffected);

    If you perform the UPDATE/DELETION there are .data with an array property

    all the results that you can browse, exhausted for example length of results

    (just treat it as type Array and iterate over it if you wish)

    trace ("result Total SQL statements:" + result.data.length);

    remove the listener

    insertStmt.removeEventListener (SQLEvent.RESULT, _runQuery);

    }

    Keep in mind, it's TO-achieve, not a total. This allows you to review the results of each "single" execute() that you are running. You can search for questions or to check the validity of the data, etc., on each function execute(). If you don't really care that then just check the _sqlConn.totalChanges for one number for everything that moved the database runs.

    Don't forget to close the connection of _sqlConn after all function execute() statements look the next time you run queries, it resets the totalChanges. Also on something like a DELETION * a SQLResult returned 0 results. It is mentioned in the documentation, read paragraph 3 on the addition of a 'WHERE 1 = 1' just to get results to fill:

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/Flash/data/SQLResult.ht ml #rowsAffected

  • Help with Sql for the annual report by month

    Hi, I got the task of creating an annual report each month that shows the benefits of the enterprise by month and total in the last column to show what branch was the hightest income.
    Branch | January | February | March | April | Can | June... | Total |
    ABC | $0.00 | $0.00 | $0.00 | $0.00 | $0.00 | $0.00 | Total of the Amt |
    DEF | $18.01. $3.88. $18.01. $4.12 | $18.01. $3.97 | Total of the Amt |

    Can someone please help me give an idea of how to write sql for this report... ? I build subqueries for everymonth giving dates for Jan/Feb/March... but I think that this is not the right way to do it...
    -----------------------------------------------------------------------------------------------------------------------
    SELECT
    Sum (a.Commission) December,
    Sum (b.Commission) November
    Of
    (
    Select
    c.account_ID,
    c.Officer,
    c.account_product_class_id,
    Sum (c.dp_monthly_premium) Commission
    Of
    c contract
    Where
    c.account_ID = 109 and
    c.Status = 'APPROVED' and
    c.protection_effective between December 1, 2009 "and on December 31, 2009"
    Group by
    c.account_ID,
    c.Officer,
    c.account_product_class_id
    ),
    (
    Select
    c.account_ID,
    c.Officer,
    c.account_product_class_id,
    Sum (c.dp_monthly_premium) Commission
    Of
    c contract
    Where
    c.account_ID = 109 and
    c.Status = 'APPROVED' and
    c.protection_effective between November 1, 2009 "-November 30, 2009"
    Group by
    c.account_ID,
    c.Officer,
    c.account_product_class_id
    ) b
    -----------------------------------------------------------------------------------------------------------
    I always hight hope this forum. So please help. Thanks in advance.

    Published by: Aditi_Seth on January 26, 2010 14:29

    You may reach the columns using decode:

    Select sum (decode (to_char (c.protection_effective, 'MM'), 1, c.dp_monthly_premium, 0)) January
    , sum (decode (to_char (c.protection_effective, 'MM'), 2, c.dp_monthly_premium, 0)) February

    etc.

    At least, this will improve efficiency, because you need only make one pass.

    no guarantee that the media are quite right - I did not execute the query, but I think that you should get the idea!

  • Need drivers of Windows XP Home for the Satellite A350 - 216 (PSAL6E)

    Hey.

    I have he will say shortly. I need DRIVERS for WINOWS XP. I have instaled Vista, I bought my Nooteboom with this system and shop where I take this nb doesn't give me a cd with drivers for this NOTE. If some 1 have grazing with drivers pliz help me :(:(:(

    «' New laptop models are delivered without driver CD or installations CD / DVD Recovery image designed for each model of mobile phone is stored on the HARD drive and if you want to have as facilities DVD you must create only using preinstalled "Toshiba Recovery Disc Creator»

    Your laptop is designed for Vista and it is also supported for new Win7 but not for the old WXP, so you will not be able to find all the drivers for Windows XP Home edition, tools and utilities on Toshiba support download page.

  • need sata drivers to format text for the installation of windows

    hey im trying to reinstall windows on my dell xps 700 desktop computer but I need drivers sata for the instalation disc (I do not have the supliet a dell me with) and I'm using nlite for this but I can't find the drivers for it I need the driver to be in textmode as nlite called someone can please help me with a download link for the drivers

    I have now completed the installation and it worked smoothly so now I just need to some drivers can any of you guide me? I don't have an Office exept empty the trash so I need some internet for beginners

    http://www.Dell.com/support/drivers/us/en/19

    For best results, put in your Service tag.  Otherwise, "choose from a list of all products Dell" > Desktops > XPS > XPS 700 Jet Black

    Read this first http://support.dell.com/support/topics/global.aspx/support/kcs/document?c=us&cs=19&l=en&s=dhs&docid=DSN_1A0C0937D62A8739E0401E0A55174744&isLegacy=true

    If there is a choice of different drivers (for example, the categories of video and audio), you should do one or more of the following to determine that you actually have material:

    1. use your serial number instead of looking for your computer in the list of all Dell products.
    2. glance in the Device Manager (start > run > devmgmt.msc > OK)
    3. look in system information (start > run > msinfo32.exe > OK)
    4. open your computer and determine the make and model of the control card

  • I need a download of software recommended for the Transcriber ICD-PX312 for Windows 7.

    I installed the software that came with the ICD-PX312 on a windows system 7 and it crashes constantly. I need a download location for the software recommended for the valid software for the Windows 7 platform.

    all links will be useful.

    Hi Tim,.

    Welcome to the community of Sony!

    Download and install the latest version of the software of the Organizer from the link below:

    http://eSupport.Sony.com/us/p/SWU-download.pl?MDL=ICDPX312&upd_id=8218&os_group_id=5

    If my post answered your question, please mark it as an "accepted Solution".

    Thank you for your message.

Maybe you are looking for