SQL - SSIS likely grouping of records.

Dear all,

There is a requirement with our customer about the grouping of coordinates based on some of the fields in the contact table.

I built an SSIS package and using the Component Manager of Script and Fuzzy Grouping. and its working perfectly according to the requirement.

But unfortunately customer uses SQL Server 2012 Standard Edition.

and fuzzy edition 2012 model, components of Transactions are not supported in SQL Server: (.)

Kindly help me to get an alternative.

Thanks in advance.

Concerning

Roopa

Hello

Support for SQL Server is not provided in these forums. On the other hand, it please repost your question Microsoft TechNet or MSDN here forum:

SQL Server forums    (TechNet)

SQL Server forums     (MSDN)

Thank you.

Tags: Windows

Similar Questions

  • assignment of sequential value that resets to a group of records

    Hello all and happy FRIDAY!

    I do a conversion of data to a new system and I can't seem to come with a query.

    Running Oracle 10.2

    Sample data:
    create table test (GRP number, PART varchar2(20), SEQ number);
    insert into test values(9000, 'lskdjf', null);
    insert into test values(9000, 'alsdk', null);
    insert into test values(9000, '492kjsfjsldk', null);
    insert into test values(9000, 'lkjasdf0982j', null);
    insert into test values(9001, 'likfjajsd', null);
    insert into test values(9001, '234-092838', null);
    insert into test values(8934, '000-192893aj', null);
    insert into test values(8934, 'anotherpart', null);
    insert into test values(8934, 'jjjj0-aa-2001', null);
    insert into test values(8934, 'encifudy', null);
    insert into test values(8934, 'asfdjslkjdfklsj', null);
    insert into test values(8934, 'lksjdflj', null);
    insert into test values(4736, 'l;ask---jdflasj', null);
    commit;
    
    Select * from test;
    Do select * at this stage will give you the elements of nulls for the third column.

    Problem:
    I'm trying to run a query that spits out a sequence for each "group" of records. If there are 5 records in a group, I would like the sequence start at 1 and go to 5... may be ordered by a party. (not quite sure that the command, but to do babysteps here): P

    Here is an example of the output data, I would like that in the example above:
    GRP     PART               SEQ
    9000     lskdjf               1
    9000     alsdk               2
    9000     492kjsfjsldk          3
    9000     lkjasdf0982j          4
    9001     likfjajsd          1
    9001     234-092838          2
    8934     000-192893aj          1
    8934     anotherpart          2
    8934     jjjj0-aa-2001          3
    8934     encifudy          4
    8934     asfdjslkjdfklsj          5
    8934     lksjdflj          6
    4736     l;ask---jdflasj          1
    In that result, SEQ is not applied to the drive control part, but ultimately, this might be something I would do. So far only community-eager to get these figures here. I read using rankover(), but it's still a bit confusing for me on how it works. I'll go than I suspect it's probably what I'll have to use a search.

    In the end, this is part of a slider that is powered by a bulk collect. I might be able to fill this SEQ in PL/SQL, but I thought it would be easier to get them just at the level of the query so that they are already part of the collection, instead of having to build the logic to create this numbering system prior to insertion of an intermediate table.

    Anyhoo... any help would be greatly appreciated! If I've omitted something or am not clear anyway, please let me know! Thank you!

    Published by: dvsoukup on July 27, 2012 16:25

    Hello

    dvsoukup wrote:
    Running Oracle 10.2

    Sample data:

    create table test (GRP number, PART varchar2(20), SEQ number);
    insert into test values(9000, 'lskdjf', null); ...
    

    Thanks for posting your version and CREATE TABLE and INSERT PMT ts; It's very useful!
    >

    Do select * at this stage will give you the elements of nulls for the third column.

    Problem:
    I'm trying to run a query that spits out a sequence for each "group" of records. If there are 5 records in a group, I would like the sequence start at 1 and go to 5... may be ordered by a party. (not quite sure that the command, but to do babysteps here): P
    I read using rankover(), but it's still a bit confusing for me on how it works.

    You got that right! Analytical functions are looking very strange and confusing at first. After awhile, they don't seem so strange, and then they get even less confusion.
    One thing to remember: "PARTITION OF x" (this is always optional) means that each value of x is a world full. It's like a separate query is made for each value of x, and when they are all finished, the results are clauses together. In this case, you want to PARTITION BY grp.

    I'll go than I suspect it's probably what I'll have to use a search.

    You are very close; only, as the first response said, it is not RANK you want, but its close relative ROW_NUMBER. The difference between the two, it's how they deal with the links. If you have duplicates, RANK assigns a number in doubles. I suppose you want the unique numbers, even if you have identical parts on the same grp.

    In the end, this is part of a slider that is powered by a bulk collect. I might be able to fill this SEQ in PL/SQL, but I thought it would be easier to get them just at the level of the query so that they are already part of the collection, instead of having to build the logic to create this numbering system prior to insertion of an intermediate table.

    It is quite easy to assign numbers when you generate the table.

    If the situation is what you have posted, that is your table already exists, but the number of seq is not filled yet, then you can do:

    MERGE INTO     test     dst
    USING   (
             SELECT  grp
             ,         part
             ,         ROW_NUMBER () OVER ( PARTITION BY  grp
                                                    ORDER BY      part
                               )       AS seq
             FROM    test
         )          src
    ON     (     src.grp          = dst.grp
         AND     src.part     = dst.part
         )
    WHEN MATCHED THEN UPDATE
    SET     dst.seq   = src.seq
    ;
    

    The MERGE statement preceding assumes that the combination (grp, part) is unique.
    Once executing, this query:

    SELECT       *
    FROM       test
    ORDER BY  grp
    ,            part
    ;
    

    will these results:

    `      GRP PART                        SEQ
    ---------- -------------------- ----------
          4736 l;ask---jdflasj               1
          8934 000-192893aj                  1
          8934 anotherpart                   2
          8934 asfdjslkjdfklsj               3
          8934 encifudy                      4
          8934 jjjj0-aa-2001                 5
          8934 lksjdflj                      6
          9000 492kjsfjsldk                  1
          9000 alsdk                         2
          9000 lkjasdf0982j                  3
          9000 lskdjf                        4
          9001 234-092838                    1
          9001 likfjajsd                     2
    

    The USING clause above is almost identical to the query, published in the last post, but in the analytic clause, instead of "ORDER BY grp", part it says "COMMANDER PARTIALLY. He never has any sense to PARTITION BY and ORDER BY the same column in the same function. Why? Discuss.

  • create dynamically a group of record based on previously entered record Grou

    Forms [32 bit] Version 10.1.2.3.0 (Production)

    Hello
    I know how to create dynamically record based on a query and put the code in when a new instance of the form.
    My request is. I have a form that includes several groups of Record and the user wants to dynamically create the following groups based on the previous groups.

    For example
    I have a record group with choosing a location.
    When the user selects the location from a list of values
    the 2nd record group called "Cost Centres" will have to filter only those whose locations selected above.

    How can I fill the 2nd record running when I don't know what site the user will choose?
    If I just simply fill in when new instance of form as the location and just select the entire document, populates the list of values.

    CC field is a LIST ELEMENT and the style of list is a LIST of POP, is not necessary.

    I put the code in the location of the trigger when-list-changed field.
    I get this error:
    FRM-41337: cannot complete the record group list

    Here is the code:

    DECLARE
    
    v_recsql Varchar2(1000); -- The SQL for creating the Record Group.
    v_recgrp RecordGroup; -- Record Group
    v_status Number; -- Return Value of Populate_Group function.
    c_where VARCHAR2(1000);
    
    BEGIN
         IF :location = '1' THEN
              c_where := ' substr(cost_centre,1,2) in (''01'',''02'')';
              
         ELSIF :location  = '2' THEN
              c_where := ' substr(cost_centre,1,2) in (''02'',''03'')';
              
         ELSIF :location   = '3' THEN
              c_where := ' substr(cost_centre,1,2) in (''01'',''11'',''07'')';
                   ELSE
              c_where :=  ' 1=1'; --EVERYTHING
    
         END IF;
    
    v_recsql := 'SELECT cost_centre, description  FROM   cost_centres  where '||c_where;
    
    
    -- Create the Record Group
    v_recgrp := CREATE_GROUP_FROM_QUERY('v_recgrp', v_recsql);
    
    
    IF NOT ID_NULL(v_recgrp)
    THEN -- No Error, record group has been successfully created.
    
    
    -- Populate Record Group
    v_status := POPULATE_GROUP('v_recgrp');
    
    
    IF v_status = 0 
    THEN -- No Error. Record Group has been Populated. 
    POPULATE_LIST('block.CC', 'v_recgrp');
    END IF; -- IF v_status = 0 
    
    -- Delete the Record Group as it is no longer needed.
    DELETE_GROUP('v_recgrp'); 
    
    
    END IF; -- IF NOT ID_NULL(v_recgrp)
    
    END;
    Thanks for your help.

    Hello
    Once registration State Gets the change to block you cannot fill/repopulate the list item. Keep these list items as element non-base of data with different names and create different items such as database Moose points. That assign values in triggering WHEN-LIST-CHANGE for real database items.

    -Clément

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • PL/SQL: ORA-00934: Group feature is not allowed here

    Hello

    I write a PL/SQL procedure. The structure is like:

    SET SERVEROUTPUT ON;
    CREATE or REPLACE procedure abc

    IS
    v_total_ip_rec number (14);
    v_total_op_rec number (14);
    v_total_rec number (14);


    BEGIN
    SELECT SUM (CASE
    WHEN < condition 1 >
    THEN 1
    0 OTHERWISE
    END
    ) in v_total_ip_rec.
    SUM (CASE
    WHEN < condition 2 >
    THEN 1
    0 OTHERWISE
    END
    ) in v_total_op_rec.
    SUM (1) in v_total_rec
    OF A, B
    WHERE A.Col1 = B.Col1;

    EXCEPTION
    WHILE OTHERS THEN
    raise_application_error (-20001,' an error has occurred - ' |) SQLCODE |' - ERROR - ' | SQLERRM);
    END;


    When I run this procedure it gives me following error:
    "PL/SQL: ORA-00934: Group feature is not allowed here."

    Someone has an idea?

    Any help would be appreciated.

    Thank you.

    Should I have any special role?

    Have you checked if synonyms exist for tables?
    Please check in this order:

    #1-synonymes appropriate
    #2-appropriate privileges
    #3-appropriate roles

  • How to select the values for each check box in a group of records

    Hello

    I have a requirement in form 10g. In this form there are 10 records are display each record has a checkbox is there if I click on the check box save number one and number three and make some changes in the text field (field adjustment is the number data type) and then finally, I want to see the total a total amount called field.

    In this, my question is how to select specific to a group of records records? and finally these selected records are inserted in a table.
    Because I am not able to read these records at a time.
    Is there any table to define a record group to fetch each of them individually for example Rec [1] Rec [2]... like this if yes please suggest me the steps how to do this.

    Thanks in advance
    Prasanna

    Published by: user10315107 on December 17, 2008 23:44

    OK, so you want to shoe the total amount in the form itself (I guess that somewhere under the dashboard lines?).

    You can do this easily using formulat elements:

    1 create a new item in your block where the field amount is places, set "section of the database" on the 'No', 'calculation mode' to the 'formula' and the 'formula' himself to something like:

    CASE WHEN :BLOCK.CHECKBOXITEM=CHECKVALUE THEN :BLOCK.AMOUNT+:BLOCK.ADJUSTMENT ELSE 0 END;
    

    This formula returns 0 if the checkboxitem is not checked, otherwise the sum of amount and adjustment (of course you can adjust the names of elements and the value for 'Checked')
    2. place the element in the layout, if you wish.
    3. set the property "Query all Records" to "true" for your block elements, this is necessary for the calculation to work
    3 create a control block to keep summary article in a, "Single Document" set to 'True '.
    4. place a new element in this control block, set 'Calcuation mode' to 'Summary', 'Summary block' to your block elements, 'Summary point' in newly created formula section in the block elements
    and function of synthesis for the "sum".
    5. place the element in the layout

    She's.

  • SQL count (*) with Group of

    Hello

    I need help to fix this SQL.

    Fields in the table are like that.
    ID(PK)
    user_id
    user_name
    login_time(timestamp)
    Basically I want the values of user_id, user_name, last time the logged-in user and total number of times the user
    select  distinct user_id , user_name, login_date from USER_LOGIN
    where login_date in (select max(login_date) from USER_LOGIN group by user_id) 
    the above query is to give the result set with user_id, user_name, last time that the user logged on, but how can I include count (*) Group of user_id in the sql above
    select  distinct user_id , user_name, login_date, count(*) from USER_LOGIN
    where login_date in (select max(login_date) from USER_LOGIN group by user_id)  group by user_id 
    the sql above does not work.

    can you help me to get the number of records by user_id group.

    Thank you
    SK

    Hello

    Looks like you want something like this:

    SELECT       user_id
    ,       user_name
    ,       MAX (login_time)     AS last_login_time
    ,       COUNT (*)          AS total_rows
    FROM       user_login
    GROUP BY  user_id
    ,            user_name
    ;
    

    This assumes that user_login is off standard (like him are often seen), such that every row of the same user_id will also have the same user_name.

    I hope that this answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.

  • How can I request the parameters of custom folder to a specific group of records under XP?

    Hello everyone.

    I'm THAT n00b-ish person asking the stupid question. But I can't understand for save the children. So I want to open with 1 million wishlist.

    I'm organizing my files of music inside the folder 'my music '. I am aware that since he is a 'special' folder, I can not customize it at the root.
    SO, I'm trying to customize the folders inside and make sure the radio button for "apply it to all subfolders" is checked. However, the options that I can apply are quite limited (essentially, I have the choice to make all files to display as thumbnails or icons, which isn't exactly the most intuitive way to search for music).
    I went to come a taken ONE of my files and converted to retail and added columns flow, track number, etc. so theoretically, I can fix my list in order: artist, title of song, duration, flow, track number, album, genre, folder

    (It's because I'm always organize a lot of my music as its most often jumbled together from various sources incorrectly appointed or mixed compilations or what have you).

    I tried everything under the Sun to figure out how to make this setting this record, applied to all of the folders inside my music. BUT there seems to be no way to save it as a template or apply it to a group of files (all I see is that I can do EVERY file on my computer that I don't want).

    Any help is very appreciated. Thanks in advance. See you soon.
    * original title - forgive my innanity, how I apply some settings to custom folder as a specific group of folders.*

    Hello

    I suggest to refer to the link below and follow the troubleshooting steps to customize folders.

    How to modify your folder view settings or customize a folder

    http://support.Microsoft.com/kb/812003

  • Using SQL to ensure the matching records are mutually exclusive.

    There are two tables defined in the following way:

    Table A

    Number 1

    Number 2

    Date

    ROWID

    Table B

    Number 1

    Number 2

    Date

    Identifier of the line

    Each table stores a call between number 1 and 2 on a specific date. The goal is to map exactly one entry of table A with exactly the record in table B

    in a mutually exclusive way. So a single call to a table must be associated with exactly one call the other table (the key is here

    A.Number1 is B.Number1 and A.Number2 = B.Number2). Because it is a relationship is many to many (the number of source and destination may be paired multiple)

    (time), I'm not able to build a series of sql statements that will allow me to get a relationship one between pairs of telephone numbers.

    I'm not allowed to develop a PL/SQL procedure, which would easily solve this problem.

    I was able to find a solution using MIN(Number 1) KEEP (DENSE_RANK FIRST ORDER BY Date) to THE (PARTITION BY x) the form x

    using temporary tables, which allows me to reach a breaking successively much many relationships (i.e. three broken bones in a 01:58 after

    an iteration, and after one iteration, I arrive at a one to one relationship). However, I can't break these relations some n number of times because it requires number n

    hard curls. Therefore, I need a sophisticated solution that will allow me to achieve a relationship one by one.

    Example of

    Table A

    Record 1

    Number 1:451923456789

    Number 2:541969432045

    Date: 29/07/2015-09:01

    Worksheet 2

    Number 1: 451923456789

    Number 2: 541969432045

    Date: 29/07/2015-09:03

    Table B

    Record 1

    Number 1: 451923456789

    Number 2: 541969432045

    Date: 29/07/2015-09:04

    Worksheet 2

    Number 1: 451923456789

    Number 2: 541969432045

    Date: 29/07/2015-09:05

    If we unite our table A and B by A.Number1 = B.Number1 and A.Number2 = B.Number2, we have 4 records. I'm looking for exactly two records.

    The criteria is to associate by the minimum of the sum of the date of the table A table B date. Therefore, the final result should match:

    (1) record 1 of table A with record 1 of table B.

    sheet 2) 2 table A with 2 record in table B.

    So we must do something to reduce the 4 records resulting from the join of two records describe as we see above.

    The result of the join:

    1st row: TableA.Record1 with TableB.Record1

    2nd place: TableA.Record1 with TableB.Record2

    Rank 3: TableA.Record2 with TableB.Record1

    4th place: TableA.Record2 with TableB.Record2

    What I'm looking for, which is easily achievable with a slider, but not with SQL:

    1st row: TableA.Record1 with TableB.Record1

    4th place: TableA.Record2 with TableB.Record2

    Note that if the minimum date condition allows us to select the necessary records, we won't get the expected results. In other words, using the minimum date.

    the results will be:

    1st row: TableA.Record1 with TableB.Record1

    Rank 3: TableA.Record2 with TableB.Record1

    (criteria - table a minimum date)

    or

    1st row: TableA.Record1 with TableB.Record1

    2nd place: TableA.Record1 with TableB.Record2

    (criteria - date minimum table B)

    Two of these results to break the rule are mutually exclusive.

    Post edited by: 3000640

    If I understand correctly, something like:

    SQL > with tableA (id, telephone1, telephone2, call_date) as)

    2. Select 1, ' 451923456789 ', ' 541969432045',

    3 to_date (July 29, 2015 09:01 ', 'dd.mm.yyyy hh24')

    4 union double all the

    5. Select 2, ' 451923456789 ', ' 541969432045',

    6 to_date (July 29, 2015 09:03 ', 'dd.mm.yyyy hh24')

    double 7),

    TableB 8 (id, telephone1, telephone2, call_date) as)

    9. Select 1, ' 451923456789 ', ' 541969432045',

    10 to_date (July 29, 2015 09:04 ', 'dd.mm.yyyy hh24')

    11 double Union all the

    12. Select 2, ' 451923456789 ', ' 541969432045',

    13 to_date (July 29, 2015 09:05 ', 'dd.mm.yyyy hh24')

    14 double)

    15 select a.id help, a.phone1 aphone1, a.phone2 aphone2,

    16 a.call_date acall_date, b.id offer, b.phone1 bphone1,

    17 b.phone2 bphone2, b.call_date bcall_date

    18 (select id, telephone1, telephone2, call_date,

    19 row_number() over (partition by numbers1, telephone2

    RN 20 order by call_date)

    tablea 21) a

    22 join (select id, telephone1, telephone2, call_date,

    23 row_number() over (partition by numbers1, telephone2

    RN 24 order by call_date)

    tableb 25) b

    26 on a.phone1 = b.phone1 and

    27 a.phone2 = b.phone2 and

    28 a.rn = b.rn;

    HELP APHONE1 APHONE2 ACALL_DATE BPHONE1 BPHONE2 BCALL_DATE OFFERS

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

    1 451923456789 541969432045 July 29, 2015 09:01 1 451923456789 541969432045 July 29, 2015 09:04

    2 451923456789 541969432045 July 29, 2015 09:03 2 451923456789 541969432045 July 29, 2015 09:05

    John

  • SQL or PL/SQL-&gt; check a grouping of several criteria in the same group.

    Hello

    Oracle 11g. I need to check a set of data for multiple filtering criteria together. If the criterion is found, the FLAG_SET is updated.

    The example data:
    MEMBER     |     GROUPING             |     CODES     |     ROW_NUMBER     |     FLAG_SET
    001          |     1               |     A          |     45               |     0
    001          |     1               |     B          |     48               |     0
    002          |     1               |     C          |     45               |     0
    002          |     1               |     C          |     49               |     0
    002          |     1               |     A          |     52               |     0
    002          |     2               |     A          |     43               |     0
    002          |     2               |     B          |     62               |     0
    002          |     2               |     B          |     63               |     0
    003          |     1               |     A          |     72               |     0
    003          |     1               |     B          |     76               |     0
    My requirement is to test if a MEMBER within a GROUPING has an 'A' and 'B' (although there are several criteria to test on for example.) "C" and had "and they are prioritized. I would test a game both in a called proc).

    I need the following output:
    MEMBER     |     GROUPING             |     CODES     |     ROW_NUMBER     |     FLAG_SET
    001          |     1               |     A          |     45               |     1
    001          |     1               |     B          |     48               |     1
    002          |     1               |     C          |     45               |     0
    002          |     1               |     C          |     49               |     0
    002          |     1               |     A          |     52               |     0
    002          |     2               |     A          |     43               |     1
    002          |     2               |     B          |     62               |     1
    002          |     2               |     B          |     63               |     1
    003          |     1               |     A          |     72               |     0
    003          |     1               |     C          |     76               |     0
    I can't just update the indicators if a single 'A' CODE is found. He must have the 'A' and 'B '.
    I tried several ways, most recently LISTAGG put all grouped values of each line and the string for CODE analysis, I lose the ROW_NUMBER when this happens but it cannot be part of the coiled LISTAGG.

    Someone at - it ideas?

    Published by: chris001 on November 28, 2012 13:33

    Hello

    You can do it with a MERGE, something like statement:

    MERGE INTO table_x     dst
    USING   (
             SELECT    mmbr     -- MEMBER is an Oracle keyword
             ,           grpng     -- GROUPING is an Oracle keyword, too
             ,           CASE
                            WHEN  COUNT ( DISTINCT CASE
                                                  WHEN codes IN ('A', 'B')
                                       THEN codes
                                      END
                              ) = 2
                     THEN  1
              --       WHEN  ...
              --       THEN  2
              --       WHEN  ...
                     ELSE  0
                        END
             FROM      table_x
             GROUP BY  mmbr
             ,           grping
         )          src
    ON     (   src.mmbr       = dst.mmbr
         AND src.grpng       = dst.grpng
         )
    WHEN MATCHED THEN UPDATE
    SET     dst.flag_set     = src.flag_set
    WHERE     dst.flag_set   != src.flag_set
    ;
    

    According to your needs.
    If you would care to post CREATE TABLE and INSERT to your sample data (as it exists before the changes), then I could test this.

    You have not need PL/SQL for this, but, if you need to do it in PL/SQL for some reason, you can.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash on November 28, 2012 16:53

  • SQL - sorting and grouping.

    Hello

    I have question posted for two days, but no help of body...
    This link

    You place your order by comparing - SQL Experts pls help

    concerning

    Published by: Ayham on October 8, 2012 02:54

    If I am clear...

    SQL> with t as
      2  (select percentage,loc1,loc2,sum(case when percentage = 0 then 1
      3                     when loc1 in (l1,l2) then 0
      4                 when loc2 in (l1,l2) then 0
      5                 when l1 is null and l2 is null then 0
      6                 else 1
      7            end) over(order by rn) sm
      8  from (     select id,location,percentage,
      9                     regexp_substr(location,'\d+',1,1) LOC1,
     10                     regexp_substr(location,'\d+',1,2)  LOC2,
     11                     lag(regexp_substr(location,'\d+',1,1))
     12                     over(order by percentage desc) l1,
     13                     lag(regexp_substr(location,'\d+',1,2))
     14                     over(order by percentage desc) l2,
     15             row_number() over(order by percentage desc) rn
     16     from temp_value
     17     order by percentage desc
     18       )
     19  )
     20  select loc,min(sm)+1 grp
     21    from(
     22      select loc,rownum rn,sm
     23      from(
     24      select percentage,decode(rn,1,loc1,loc2) loc,sm
     25      from t a,
     26           (select 1 rn from dual union all
     27            select 2 from dual ) b
     28      order by percentage desc,decode(rn,1,loc1,loc2) asc
     29     )
     30  )
     31   group by loc
     32  order by min(sm),min(rn);
    
    LOC                         GRP
    -------------------- ----------
    4                             1
    5                             1
    2                             1
    1                             1
    6                             2
    3                             3
    
    6 rows selected.
    
  • Extraction of extensible in PL/SQL SOAP envelope group

    Hi all.

    I have the following in an XMLTYPE variable in PL/SQL SOAP envelope.

    <? XML version = "1.0" encoding = "UTF - 8"? >
    < env:Envelope xmlns:env = "http://schemas.xmlsoap.org/soap/envelope/" container = "http://www.w3.org/2001/XMLSchema" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0 = "http://elmarwsoicdvmws/types/" >
    < env:Body >
    < ns0:getDVMValuesResponseElement >
    < ns0:result >
    < ns0:dvmValues > 10 < / ns0:dvmValues >
    < ns0:dvmValues > 11 < / ns0:dvmValues >
    < ns0:dvmValues > 12 < / ns0:dvmValues >
    < ns0:errorText > Ok < / ns0:errorText >
    < ns0:errorCode > 0 < / ns0:errorCode >
    < / ns0:result >
    < / ns0:getDVMValuesResponseElement >
    < / env:Body >
    < / env:Envelope > '

    I can extract the code of error and ErrorText variable without too much effort (even if I don't know there are easier ways), but now I have to extract the repeating group of dvmValues in a variable of type table.

    Any ideas/code snippets would be greatly appreciated, as I've read tons of docs and half the time they are too complex or too simplistic (given my ns0: variables), and it seems that many functions I use have been depricated.

    Kind regards

    Elmar

    Hi Elmar,

    Using a separate function to analyze the individual nodes is not necessary.
    You can extract all with a single query, thus eliminating the need to access the same document several times.

    For example, once you have the content in the RESP xmltype variable, you can do:

    SQL> create type dvmValues_t as table of number;
      2  /
    
    Type created
    
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2
      3    resp         xmltype;
      4    v_errorText  varchar2(2000);
      5    v_errorCode  number;
      6    v_dvmValues  dvmValues_t;
      7
      8  BEGIN
      9
     10    resp := xmltype('
     11  
     12  
     13  
     14  
     15  10
     16  11
     17  12
     18  Ok
     19  0
     20  
     21  
     22  
     23  ');
     24
     25    select x.errorText
     26         , x.errorCode
     27         , cast(
     28             multiset(
     29               select dvmValue
     30               from xmltable('*' passing x.dvmValues
     31                                 columns dvmValue number path '.')
     32             )
     33             as dvmValues_t
     34           )
     35    into v_errorText
     36       , v_errorCode
     37       , v_dvmValues
     38    from xmltable(
     39           xmlnamespaces(
     40             'http://schemas.xmlsoap.org/soap/envelope/' as "env"
     41           , default 'http://elmarwsoicdvmws/types/'
     42           )
     43         , '/env:Envelope/env:Body/getDVMValuesResponseElement/result'
     44           passing resp
     45           columns
     46             errorText  varchar2(2000)  path 'errorText'
     47           , errorCode  number          path 'errorCode'
     48           , dvmValues  xmltype         path 'dvmValues'
     49         ) x
     50    ;
     51
     52    dbms_output.put_line('Error Text = ' || v_errorText);
     53    dbms_output.put_line('Error Code = ' || v_errorCode);
     54
     55    for i in 1..v_dvmValues.count loop
     56      dbms_output.put_line('Value(' || to_char(i) || ') = ' || v_dvmValues(i));
     57    end loop;
     58
     59  END;
     60  /
    
    Error Text = Ok
    Error Code = 0
    Value(1) = 10
    Value(2) = 11
    Value(3) = 12
    
    PL/SQL procedure successfully completed
     
    
  • SQL query to group data by Code and dates

    Hello

    I have the following table structure

    col1 col2 col3
    January 21, 2012 tested Code1
    January 20, 2012 tested Code1
    June 1, 2012 tested Code1
    June 1, 2012 tested Code2
    code 3 tested June 4, 2012

    so now

    The output should be something like

    code week1 week semaine2 3 semaine4 week5 until the last 14 weeks from the date that we run
    code 1 1 0 0 0 0
    Code2 1 0 0 0 0
    code 3 0 1 0 0 0

    where 1, 0 is in fact the charges and no sum and the week in this case perhaps should since we are in the second week, he should be

    code... .week3 may semaine4 peut week1 jun week2june


    Was looking for suggestions on how to achieve this.

    I guess that this would require some kind of a pivot query?

    Thank you
    Sun

    Hello

    Here's how you can make this pivot in Oracle 10.2. (In fact, it will work in Oracle 9.1 or higher.)

    WITH  got_week_num  AS
    (
         SELECT  error_code, date_logged
         ,     1 + FLOOR ( ( TO_DATE (:end_dt_txt, 'DD-Mon-YYYY') - date_logged)
                         / 7
                     )     AS week_num
         FROM    data_analysis
         WHERE     date_logged     >= TO_DATE (:start_dt_txt, 'DD-Mon-YYYY')
         AND     date_logged     <  TO_DATE (:end_dt_txt,   'DD-Mon-YYYY') + 1
    )
    ,     all_weeks     AS
    (
         SELECT     LEVEL               AS week_num
         ,     TO_CHAR ( 1 + TO_DATE (:end_dt_txt, 'DD-Mon-YYYY')
                       - (7 * LEVEL)
                   , 'fmDD-Mon-YYYY'
                   )          AS heading
         FROM    dual
         CONNECT BY     LEVEL <= 1 + FLOOR ( ( TO_DATE (:end_dt_txt,   'DD-Mon-YYYY')
                                             - TO_DATE (:start_dt_txt, 'DD-Mon-YYYY')
                                  )
                                / 7
                                )
    )
    SELECT       NULL                                   AS error_code
    ,       MIN (CASE WHEN week_num =  1 THEN heading END)     AS week_1
    ,       MIN (CASE WHEN week_num =  2 THEN heading END)     AS week_2
    --       ...
    ,       MIN (CASE WHEN week_num =  5 THEN heading END)     AS week_5
    FROM       all_weeks
           --
         UNION ALL
                --
    SELECT       error_code
    ,       TO_CHAR (COUNT (CASE WHEN week_num =  1 THEN 1 END))     AS week_1
    ,       TO_CHAR (COUNT (CASE WHEN week_num =  2 THEN 1 END))     AS week_2
    --       ...
    ,       TO_CHAR (COUNT (CASE WHEN week_num =  5 THEN 1 END))     AS week_5
    FROM       got_week_num
    GROUP BY  error_code
                 --
    ORDER BY  error_code     NULLS FIRST
    ;
    

    Output:

    ERROR_CODE WEEK_1      WEEK_2      WEEK_5
    ---------- ----------- ----------- -----------
               4-Jun-2012  28-May-2012 7-May-2012
    a          3           0           0
    b          0           2           1
    c          0           0           1
    

    Once more, the number of columns, such as aliases, is hard-coded in the query.
    If you want the number of columns, or their aliases depends on the data in the table, then you need dynamic SQL. See {message identifier: = 3527823}

    Did you ever what defined a "week" is in this query?
    The query above makes week_1 end to the given date (: end_dt_txt). The first week (in other words, an ioncluding: start_dt_txt) may have less than 7 days.
    If you want all the weeks to start Monday (in which case, the first and the last few weeks may have less than 7 days) see stew solution, using TRUNC (date_logged, 'IW').

  • Stuck on a sql query to search for records that have the same parent child records

    Oracle 10 g 2 Enterprise Edition.

    Hello

    I'm writing a logic to find records in a parent table, who have the same values in a child table.
    This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
    the problem is that I'm stuck.
    Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
    The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
    many managers.

    I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
    -- parent table
    CREATE TABLE manager (
     id      number primary key,
     name      varchar2(100));
    
    -- child table 
    CREATE TABLE employee (
     id          number primary key,
     name      varchar2(100));
    
    -- link table
    CREATE TABLE join_table (
     manager_id          NUMBER, 
     employee_id      NUMBER,
     CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id),
     CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id),
     CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) 
     );
    
    -- Insert some managers
    INSERT INTO manager (id, name) VALUES (1, 'John');
    INSERT INTO manager (id, name) VALUES (2, 'Bob');
    INSERT INTO manager (id, name) VALUES (3, 'Mary');
    INSERT INTO manager (id, name) VALUES (4, 'Sue');
    INSERT INTO manager (id, name) VALUES (5, 'Alan');
    INSERT INTO manager (id, name) VALUES (6, 'Mike');
    
    -- Insert some employees 
    INSERT INTO employee (id, name) VALUES (101, 'Paul');
    INSERT INTO employee (id, name) VALUES (102, 'Simon');
    INSERT INTO employee (id, name) VALUES (103, 'Ken');
    INSERT INTO employee (id, name) VALUES (104, 'Kevin');
    INSERT INTO employee (id, name) VALUES (105, 'Jack');
    INSERT INTO employee (id, name) VALUES (106, 'Jennifer');
    INSERT INTO employee (id, name) VALUES (107, 'Tim');
    
    -- Insert the links
    -- John manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103);
    -- Bob manages Paul, Simon, Kevin, Jack
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105);
    -- Mary manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107);
    -- Sue manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107);
    -- Alan manages Paul, Simon, Ken, Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107);
    -- Mike manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103);
    
    -- For sanity
    CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
    If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.
    Answer should be Mike.
    If I ask for Manager of Mary, the answer should be Sue.

    This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
    SELECT DISTINCT m.name AS manager
    FROM manager m, join_table jt, employee e
    WHERE m.id = jt.manager_id
    AND jt.employee_id = e.id
    AND e.id IN (
         SELECT e.id
         FROM manager m, join_table jt, employee e
         WHERE m.id = jt.manager_id
         AND jt.employee_id = e.id
         AND m.name = 'John')
    ORDER BY 1;
    I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.
    Any ideas?
    BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.

    What about...

    WITH manager_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id
      AND   m.name = :P_MANAGER)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    ), all_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    )
    SELECT a.*
    FROM   manager_list m,
           all_list a
    WHERE  m.employees = a.employees
    

    Would be easier in 11g, but I do not have a facility here so this is based on 10g.

    See you soon

    Ben

  • Concatenation of fields for the Group of records

    Dear friends,

    Here's my detail records


    employee not non-contact
    1360 8934
    1360 7172
    1360 [email protected]
    1297-8933
    1297 7056
    1297 8888
    1297 xyzl

    I want to write to the bottom of the query that returns the following result set

    1360 [email protected] 8934,7172,
    1297 8933,7056,8888, xyzl

    Pls help me!

    Manish Manyal

    See: http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

    An example:

    SQL> -- generating sample data
    SQL> with t as (
      2  select 1360 employee_no, '8934' contact_no from dual union
      3  select 1360, '7172' from dual union
      4  select 1360, '[email protected]' from dual union
      5  select 1297, '8933' from dual union
      6  select 1297, '7056' from dual union
      7  select 1297, '8888' from dual union
      8  select 1297, 'xyzl' from dual
      9  )
     10  --
     11  -- actual query:
     12  --
     13  select employee_no
     14  ,      ltrim(sys_connect_by_path(contact_no, ','), ',') contact_no
     15  from ( select employee_no
     16         ,      contact_no
     17         ,      row_number() over (partition by employee_no order by contact_no) rn
     18         from   t
     19       )
     20  where connect_by_isleaf=1
     21  start with rn=1
     22  connect by rn=prior rn+1
     23         and employee_no = prior employee_no;    
    
    EMPLOYEE_NO CONTACT_NO
    ----------- --------------------------------------------------
           1297 7056,8888,8933,xyzl
           1360 7172,8934,[email protected]
    

Maybe you are looking for

  • apt - get

    Hello I need help with the command apt - get install. I know that I need tool command line that I had already installed, but how do I activate the apt - get on Mac - OSX?

  • Satellite Pro 2100 won't start at all - LED flash

    My SP2100 began to have feeding problems and now won't start at all. The AC adapter green LED is lit, that are relevant lights on the body of the laptop (although the "battery charge" light always orange these days). When I try the switch on, startup

  • Possibility to update graphics card on the Satellite P100 - 10 p

    Hello I bought a laptop from Toshiba Satellite P100 - 10 p which has a Geforce Go 7900GS inside.Will be always possible to switch to the graphic card Geforce 8 series (for example Geforce Go 8800 GS) Thanks in advance

  • How to create a trifold in Pages 5.6.1 brochure?

    I would create a trifold in Pages 5.6.1 brochure but are not models to choose from.  A Google search indicates that there used to be three-tiered models, but it seems that it is no more.  So is it possible to do it manually, other than the creation o

  • Activation of scripts on the Web server

    I found this, but cannot locate Scripting on the Web Server: Configuration page Activation of scripts on the Web server To use the script with a Web service, you must enable the feature on the Web of LabVIEW server. In LabVIEW, select the script on t