Group records as well as frequent mailers

Hi people,

I'm looking at a scenario where I would like to group the dates together (for the most part, we assume they are similar and close enough dates and so probably on the same date) when they are close together. The idea is to eliminate the possible duplicates.

Create table scripts and INSERT into the table:

create table orders_tb (order_id varchar2(4), order_date date);

insert into orders_tb (order_id,order_date) values ('1001',to_date('31-DEC-13','DD-MON-RR'));
insert into orders_tb (order_id,order_date) values ('1001',to_date('02-JAN-14','DD-MON-RR'));
insert into orders_tb (order_id,order_date) values ('1001',to_date('06-JAN-14','DD-MON-RR'));
insert into orders_tb (order_id,order_date) values ('1001',to_date('12-JAN-14','DD-MON-RR'));
insert into orders_tb (order_id,order_date) values ('1002',to_date('02-FEB-14','DD-MON-RR'));
insert into orders_tb (order_id,order_date) values ('1002',to_date('02-MAR-14','DD-MON-RR'));
insert into orders_tb (order_id,order_date) values ('1002',to_date('02-MAR-14','DD-MON-RR'));

If I ran the following SELECT statement, I would get 6 entries:

select distinct order_id, order_date from orders_tb order by order_id, order_date;

However, for the most part, I would like to Order ID 1001 subject only two records. The rule for including dates, that is all the dates to be within 10 days of the date of MIN.

1001 31-DEC-2013
1001 12-JAN-2014

Regarding the command ID 1002, he will tell you that the dates are very far.

1002 02-FEB-2014
1002 02-MAR-2014

Any help would be greatly appreciated.

Thank you!

Hello

You want to always 2 rows for each order_id exit or you want sometimes 1 or 3 or more?

You can test it with a little more data sample that test situations like these.  For example, in addition to the sample data that you posted:

insert into orders_tb (order_id, order_date) values ('1001 ', to_date('13-JAN-2014','DD-MON-YYYY'));

insert into orders_tb (order_id, order_date) values ('1001 ', to_date('19-JAN-2014','DD-MON-YYYY'));

insert into orders_tb (order_id, order_date) values ('1001 ', to_date('25-JAN-2014','DD-MON-YYYY'));

insert into orders_tb (order_id, order_date) values ('1003 ', to_date('01-JAN-2014','DD-MON-YYYY'));

insert into orders_tb (order_id, order_date) values ('1003 ', to_date('10-JAN-2014','DD-MON-YYYY'));

Here's one way:

WITH got_next_date AS

(

SELECT DISTINCT

order_id, order_date

MIN (order_date) over (PARTITION BY order_id) AS start_date

MIN (order_date) over (PARTITION BY order_id

ORDER BY order_date

RANGE BETWEEN 10.000001 MORE

AND UNBOUNDED FOLLOWING

), Next_date

Of orders_tb

)

SELECT order_id, order_date

OF got_next_date

START WITH order_date = start_date

CONNECT BY order_date = next_date PRIOR

AND order_id = order_id PRIOR

;

Output (including the sample data, I added):

ORDER_ID, ORDER_DATE

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

1001 December 31, 2013

1001 12 January 2014

1001 January 25, 2014

1002 February 2, 2014

1002 2 March 2014

1003 1 January 2014

Tags: Database

Similar Questions

  • SQL to group records and apply logic to pick up a record of each group

    Hi friends,

    I am looking for a query group records on some columns in a table and then each group I want to take just a single folder according to certain rules.

    Could have given arranged at will to make my point more clear for you. Here you go:
    CREATE TABLE AD_LIST
    (
      FILE_NAME             VARCHAR2(50 BYTE),
      ACTIVITY_START        DATE,
      ACTIVITY_END          DATE,
      DIVISION              VARCHAR2(50 BYTE),
      ITEM_CODE             VARCHAR2(50 BYTE),
      MULT                  NUMBER,
      RETAIL                NUMBER,
      AD_PAGE               VARCHAR2(1 BYTE),
      FORECAST              NUMBER,
      MEMO                  VARCHAR2(50 BYTE)
      );
    
    INSERT INTO AD_LIST VALUES ('FILE_1','01-APR-2010','15-APR-2010','B',1111,5,10,'A',10,'This must be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','01-APR-2010','15-APR-2010','B',1111,1,1,'B',15,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','01-APR-2010','15-APR-2010','B',1111,6,15,'C',11,'Must not be in my result');
    
    INSERT INTO AD_LIST VALUES ('FILE_1','16-APR-2010','30-APR-2010','N',1111,4,20,'D',40,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','16-APR-2010','30-APR-2010','N',1111,5,15,'E',30,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','16-APR-2010','30-APR-2010','N',1111,1,2,'F',20,'This must be in my result');
    
    CREATE TABLE PAGE_RANK
    (
      AD_PAGE VARCHAR2(1 BYTE),
      RANK NUMBER
    );
    
    INSERT INTO PAGE_RANK VALUES ('A',1);
    INSERT INTO PAGE_RANK VALUES ('B',2);
    INSERT INTO PAGE_RANK VALUES ('C',3);
    INSERT INTO PAGE_RANK VALUES ('D',4);
    INSERT INTO PAGE_RANK VALUES ('E',5);
    INSERT INTO PAGE_RANK VALUES ('F',6);
    COMMIT;
    
    SELECT * FROM AD_LIST
    
    FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    -----     --------     ---------     ---     ----     ----     -----     ----     ------     -----------------------     
    FILE_1     4/1/2010     4/15/2010     B     1111     5     10     A     10     This must be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     B     15     Must not be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     6     15     C     11     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     4     20     D     40     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     5     15     E     30     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     F     20     This must be in my result
    Now, the AD_LIST table I want to group records based on FILE_NAME, ACTIVITY_START, ACTIVITY_END, DIVISION, ITEM_CODE.
    So, in my example here, we have 2 grouped recordset based on the specified columns.

    Also, we have a table, PAGE_RANK, who has a rank corresponding to each issue of ad_page. 1. This is a rank higher than 2. This is why page ad 'A' takes precedence over 'B '. The same for all the other pages of ads.

    Now, we need to choose an announcement of each ad group in determining page ad rank higher within the Group and the value of mult and retail should be replaced by the value that has min(retail/mult). So, using the above data we will have with the full-page ad = 'A' and ad = page had ' as final results since they have the highest grade of advertising page in their group.
    The value of values mult and details of ad_page 'A' = min (10/5, 1/1, 15/6) = 1,1(mult,retail).
    The value of values mult and detail of ad_page would be ' = min (20/4, 15/5, 2/1) = 1,2(mult,retail).

    Finally I have this query below
    SELECT a.file_name,
           a.activity_start,
           a.activity_end,
           a.division,
           a.item_code,
           FIRST_VALUE (a.mult) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                    a.mult))
                                                                                                        mult,
           FIRST_VALUE (a.retail) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                      a.mult))
                                                                                                      retail,
           FIRST_VALUE (a.ad_page) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (b.RANK))
                                                                                                     ad_page,
           a.forecast,
           a.memo                                                                                                 
      FROM ad_list a, page_rank b
     WHERE a.ad_page = b.ad_page
    This query is giving me all the records, but with the values of what I wanted in the columns Ad_Page, Mult, and retail.
    How can I take only one of each group.

    I get this
    FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    -----     --------     ---------     ---     ----     ----     -----     ----     ------     -----------------------     
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     15     Must not be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     10     This must be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     11     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     20     This must be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     30     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     40     Must not be in my result
    But I want this
    FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    -----     --------     ---------     ---     ----     ----     -----     ----     ------     -----------------------     
    
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     10     This must be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     20     This must be in my result
    I have to run this query for thousands of such combination of group.
    Hope someone can shed some light on this query.

    Thanks in advance,
    Raj.

    Hello

    This is called a Query Top - N .

    How do you determine which line of each group you want to display?
    If this is the line with forecasts as low, then:

    WITH   got_r_num     AS
    (
    SELECT a.file_name,
           a.activity_start,
           a.activity_end,
           a.division,
           a.item_code,
           FIRST_VALUE (a.mult) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                    a.mult))
                                                                                                        mult,
           FIRST_VALUE (a.retail) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                      a.mult))
                                                                                                      retail,
           FIRST_VALUE (a.ad_page) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (b.RNK))
                                                                                                     ad_page,
           a.forecast,
           a.memo,
           ROW_NUMBER () OVER ( PARTITION BY  a.file_name
                                   ,                  a.activity_start
                       ,            a.activity_end
                       ,            a.division
                       ,            a.item_code
                       ORDER BY       a.forecast
                     )      AS r_num
      FROM ad_list a, page_rank b
     WHERE a.ad_page = b.ad_page
    )
    SELECT file_name,
           activity_start,
           activity_end,
           division,
           item_code,
           forecast,
           mult,
           retail,
           ad_page,
           memo
    FROM   got_r_num
    WHERE  r_num     = 1
    ;
    

    If it is something else, then change the ORDER BY clause in the ROW_NUMBER function.

  • Group records with time

    Hi all

    This is our requirement.

    We must combine records with time.

    for example: period = 3
    TABLE: XX_SALES
    ---------------------------------------------
    XDATE XQTY
    ---------------------------------------------
    10 5/1/2012
    20 2/5/2012
    3/5/2012 30
    4/5/2012 60
    12 2012/5/7
    8/5/2012 23
    45 8/5/2012
    100 12/5 / 2012
    5/2012/13 55
    5/2012/15 99

    == >
    ---------------------------------------------
    XDATE XQTY
    ---------------------------------------------
    1/5/2012 10-> 5/1/2012 Group (5/1/2012 ~ 3/5/2012)
    2/5/2012 20-> 5/1/2012 Group (5/1/2012 ~ 3/5/2012)
    3/5/2012 30-> 5/1/2012 Group (5/1/2012 ~ 3/5/2012)
    4/5/2012 60-> Group 5/2012/4 (4/5/2012 ~ 2012/5/6) *.
    7/5/2012 12-> Group 5/2012/7 (5/7/2012 ~ 9/5/2012) *.
    8/5/2012 23-> Group 5/2012/7 (5/7/2012 ~ 9/5/2012) *.
    8/5/2012 45-> Group 5/2012/7 (5/7/2012 ~ 9/5/2012) *.
    5/2012/12 100-> Group 5/12/2012 (2012/5/12 ~ 14/5/2012) *.
    13/5/2012 55-> Group 5/12/2012 (2012/5/12 ~ 14/5/2012) *.
    5/15/2012 99-> Group 5/15/2012 (15/5/2012 ~ 5/17/2012) *.

    After amount to combine with period = 3, the result will be
    ---------------------------------------------
    XDATE_G XQTY_G
    ---------------------------------------------
    60 1/5/2012
    4/5/2012 60
    2012/5/7 80
    12/5/2012 155
    5/2012/15 99


    Here's the example script
     
    create table XX_SALES(XDATE DATE, XQTY Number);
    insert into XX_SALES VALUES(to_date('20120501','YYYYMMDD'),10);
    insert into XX_SALES VALUES(to_date('20120502','YYYYMMDD'),20);
    insert into XX_SALES VALUES(to_date('20120503','YYYYMMDD'),30);
    insert into XX_SALES VALUES(to_date('20120504','YYYYMMDD'),60);
    insert into XX_SALES VALUES(to_date('20120507','YYYYMMDD'),12);
    insert into XX_SALES VALUES(to_date('20120508','YYYYMMDD'),23);
    insert into XX_SALES VALUES(to_date('20120508','YYYYMMDD'),45);
    insert into XX_SALES VALUES(to_date('20120512','YYYYMMDD'),100);
    insert into XX_SALES VALUES(to_date('20120513','YYYYMMDD'),55);
    insert into XX_SALES VALUES(to_date('20120515','YYYYMMDD'),99);
     
    We can solve this problem by using the loop now:
    to find the XDATE_G and it's rank in the loop and the XQTY in the range of the sum.
    DECLARE
      V_DATE_FROM DATE := NULL;
      V_DATE_TO   DATE := NULL;
      V_QTY_SUM   NUMBER := 0;
      CURSOR CUR_DATE IS
        SELECT DISTINCT XDATE FROM XX_SALES ORDER BY XDATE;
    BEGIN
      FOR REC IN CUR_DATE LOOP
        IF V_DATE_TO IS NULL OR REC.XDATE > V_DATE_TO THEN
          V_DATE_FROM := REC.XDATE;
          V_DATE_TO   := REC.XDATE + 3 - 1;
          SELECT SUM(XQTY)
            INTO V_QTY_SUM
            FROM XX_SALES
           WHERE XDATE >= V_DATE_FROM
             AND XDATE <= V_DATE_TO;
          DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_DATE_FROM, 'YYYYMMDD') ||
                               '-----qty: ' || TO_CHAR(V_QTY_SUM));
        END IF;
      END LOOP;
    END;
    Is it possible to solve this problem by using analyze sql?


    Thanks in advance,
    Best regards
    Zhxiang

    Published by: zhxiangxie on April 26, 2012 14:41 fixed the grouping expected data

    There was an article about a similar problem in Oracle Magazine recently:

    http://www.Oracle.com/technetwork/issue-archive/2012/12-Mar/o22asktom-1518271.html

    See the section on the 'grouping beaches '. They needed a total cumulative who started once the total reaches a certain amount.

    You need a total cumulative which starts again when the date changes to group and the dates of beginning and end of each group must be determined dynamically.

    This can be done with the analytical functions.

    Here is a solution-based 'code listing 5', the solution MODEL, which is recommended in the article.

    SELECT FIRST_DATE, SUM(XQTY) SUM_XQTY FROM (
      SELECT * FROM xx_sales
      MODEL DIMENSION BY(ROW_NUMBER() OVER(ORDER BY XDATE) RN)
      MEASURES(XDATE, XDATE FIRST_DATE, XQTY)
      RULES(
        FIRST_DATE[RN > 1] =
          CASE WHEN XDATE[CV()] - FIRST_DATE[CV() - 1] >= 3
          THEN xdate[cv()]
          ELSE FIRST_DATE[CV() - 1]
          END
      )
    )
    GROUP BY first_date ORDER BY first_date;
    
    FIRST_DATE            SUM_XQTY
    --------------------- --------
    2012/05/01 00:00:00         60
    2012/05/04 00:00:00         60
    2012/05/07 00:00:00         80
    2012/05/12 00:00:00        155
    2012/05/15 00:00:00         99
    

    If you 9i, there is no function model. In this case, I can give you a solution using START WITH / CONNECT BY that does not work as well.

  • BlackBerry smartphone how to change view Contact to see category / group records only

    Hi everyone, just got my first BlackBerry.

    The Bold (9000) is the best screen.

    To be honest, I was anti-BlackBerry when they first came out.

    Did not like the feel of plastic.

    Now that the "BOLD" is here, and for some time, finally I turned.

    After using it for only a week, I must say, I am very impressed and now intend to continue to use it.

    I will also continue to have a second very basic phone.

    I thought that most of the things, even added many additional services, most of them style of Google.

    SE BIS, soon change BES to access our new SBS Exchange work.

    Even some of the most difficult functions, services and settings can be solved for me.

    I do not work in a dealership take Optus, mainly focused on business.

    On the issue...

    Is it possible to get your hands (first / default) connect with view to display the 'files' only category.

    I really wish I could open my contacts, select my category, then search.

    For me, it would be so much easier.

    For example. CONTACTS-Office-Steve

    or CONTACTS-family-MOM

    or CONTACTS-friends-David

    or CONTACTS-Optus-Wireless Technical Support

    This would save search me, especially since some contacts may have a different name, then I expect first (for example, 'hundreds' of Optus numbers, can be 'Pre-activation ULL' or 'Fixed installation support line')

    I guess he will have to show contacts that have not been assigned to a group (category).

    If these contacts have been enumerated below the category records, it would be ideal (for me).

    Perhaps, even if there was a possibility to classify them with the records of the category FIRST then all contacts in alpha?

    I know that a contact can be assigned to several categories (very useful).

    If this isn't an option, are there any recommended additional applications that can do this?

    I hope as clean and efficient as BlackBerry original aps.

    A few years ago, I used a Windows based mobile/PDA.

    To get more out of it, I also installed several aps SPB.

    Ultimately if an additional access point is required and is not free (IE must buy), it would really need a trial period.

    Thanks to anyone for ANY Advisor.

    I'm happy to be part of a more professional group.

    Ian

    This option as a view is not available on the BlackBerry, and I'm not aware of any third-party application to do, there could be.

    One option would be to name all your groups in such a way that they would appear first in your Contact list.

    As instead of naming a group of 'Friends', you would be the name "." See list Friends"with a period at the beginning, which will force this group name to the top of the Contact.

  • FILL MONTHS DYNAMICALLY IN THE ITEM VIA ORACLE FORMS GROUP RECORDING LIST

    Experts

    I have a query in oracle forms. I need to fill Last_Month, Current_Month & Next_month based on Sys_Date in the list box. I am able to get the values in SQL if I run the query below, but when I use the version of Oracle Forms 10.1.2.0.2, I could not get the values of Mr. can you please guide me where I'm wrong.

    declare

    v_rg_id recordgroup: = NULL;

    Number of V_errorcode;

    v_rg_salmth varchar2 (30): = "MONTHS";

    Begin

    v_rg_id: = find_group (v_rg_salmth);

    If id_null (v_rg_id) then

    v_rg_id: = create_group_from_query (v_rg_salmth,

    "WITH (AS MONTH_COUNTER)

    SELECT LEVEL 2 AS ID

    OF THE DOUBLE

    CONNECT BY LEVEL = 2

    UNION

    SELECT LEVEL AS ID

    OF THE DOUBLE

    CONNECT BY LEVEL = 0

    )

    SELECT TO_CHAR (ADD_MONTHS (TO_CHAR (SYSDATE), ID), MONTH) AS MONTH_COUNTER MONTHS ');

    v_errorcode: = populate_group (v_rg_id);

    If v_errorcode = 0 then

    message ("record group filled with data");

    on the other

    message ("V_errorcode is:" | ") v_errorcode);

    end if;

    End if;

    populate_list('MASTER.) MONTH, v_rg_id);

    end;

    The rather complicated query, try

    SELECT ADD_MONTHS (SYSDATE-1) TO DOUBLE

    UNION ALL

    SELECT SYSDATE DOUBLE

    UNION ALL

    SELECT THE DOUBLE ADD_MONTHS(SYSDATE,1)

    BTW. to use a query to populate a list, you must select two values, a label and a value, check it fill listitems dynamically - Andreas Weiden - on Oracle

  • Group records between trade unions

    Gurus,

    It's been a while since I formatted in SQL, but I have developed the following query, which gives me the result below:
         select distinct created_by, count(created_by) receipt_count,  null deliver_count
         from  wms_transaction
         where creation_date > sysdate-10
         and   transaction_type = 'RECEIPT'
         group by  created_by
       union
         select distinct created_by,  null rec_count,  count(created_by) deliver_count
         from  wms_transaction
         where creation_date > sysdate-10
         and   transaction_type = 'DELIVER'
         group by created_by   
         order by receipt_count
    
    CREATED_BY    RECEIPT_COUNT     DELIVER_COUNT
    --------------------   -----------------------     ------------------------
    SPRECKO                    4
    HKUMAR                     4
    SPRECKO                                            10
    HKUMAR                                           856
    The desired output is a user consolidated without additional records...
    CREATED_BY    RECEIPT_COUNT     DELIVER_COUNT
    --------------------   -----------------------     ------------------------
    SPRECKO                    4                       10
    HKUMAR                     4                     856
    Someone there all of the recommendations? I give the points to obtain useful and accurate responses (someone always comments on the points system when I write that ;-))

    Thank you
    Scott

    Published by: sreese on April 25, 2013 14:23

    Published by: sreese on April 25, 2013 14:23

    Hello

    You can do it with a pivot:

    select    created_by
    ,        count ( CASE
                      WHEN  transaction_type = 'RECEIPT'
                    THEN  created_by
                END
              )     as receipt_count
    ,        count ( CASE
                      WHEN  transaction_type = 'DELIVER'
                    THEN  created_by
                END
              )     as deliver_count
    from      wms_transaction
    where        creation_date    > sysdate - 10
    and          transaction_type IN ('DELIVER', 'RECEIPT')
    group by  created_by
    ;
    

    It will be much more effective than a UNION.

    The query above works in Oracle 8.1 or more. From Oracle 11, you can also use SELECT... PIVOT.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    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 25 April 2013 14:37

  • Grouping records

    Hi all

    I have this table
    WITH taba
            AS (SELECT   83573 AS id, 135433 AS pe_rule_id, 46493 AS uc_id
                  FROM   DUAL
                UNION ALL
                SELECT   83574 AS id, 135433 AS pe_rule_id, 46512 AS uc_id
                  FROM   DUAL
                UNION ALL
                SELECT   83557 AS id, 137004 AS pe_rule_id, 47277 AS uc_id
                  FROM   DUAL
                UNION ALL
                SELECT   83558 AS id, 139647 AS pe_rule_id, 47277 AS uc_id
                  FROM   DUAL
                UNION ALL
                SELECT   83571 AS id, 144804 AS pe_rule_id, 46493 AS uc_id
                  FROM   DUAL
                UNION ALL
                SELECT   83572 AS id, 144804 AS pe_rule_id, 46512 AS uc_id
                  FROM   DUAL)
    SELECT   *
      FROM   taba
    I need to get all records with MIN (ID), that have the same group uc_id records.
    Return:
    135433 46493
    46512 135433
    137004 47277

    For example, 2 = 144804 pe_rule_id records have both the same uc_id as the chronogram pe_rule_id = 135433 2. In this case, I need only the records pe_rule_id = 135433

    This is just one example. I may have records with 3 or more uc_id diferent to the same pe_rule_id.

    Can you help me please?
    Thank you

    Filipe Almeida

    Do you mean min (pe_rule_id)?

    Like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH taba
      2          AS (SELECT   83573 AS id, 135433 AS pe_rule_id, 46493 AS uc_id
      3                FROM   DUAL
      4              UNION ALL
      5              SELECT   83574 AS id, 135433 AS pe_rule_id, 46512 AS uc_id
      6                FROM   DUAL
      7              UNION ALL
      8              SELECT   83557 AS id, 137004 AS pe_rule_id, 47277 AS uc_id
      9                FROM   DUAL
     10              UNION ALL
     11              SELECT   83558 AS id, 139647 AS pe_rule_id, 47277 AS uc_id
     12                FROM   DUAL
     13              UNION ALL
     14              SELECT   83571 AS id, 144804 AS pe_rule_id, 46493 AS uc_id
     15                FROM   DUAL
     16              UNION ALL
     17              SELECT   83572 AS id, 144804 AS pe_rule_id, 46512 AS uc_id
     18                FROM   DUAL)
     19  select pe_rule_id, uc_id
     20  from taba where pe_rule_id in (
     21     SELECT   min(pe_rule_id)
     22     FROM   taba
     23     group by uc_id
     24*    having count(*) > 1)
    SQL> /
    
    PE_RULE_ID      UC_ID
    ---------- ----------
        137004      47277
        135433      46512
        135433      46493
    

    Published by: BluShadow on August 3, 2011 13:26
    p.s. Thanks for providing data in an easy to use format. :)

  • Output and group records into several column format problem

    Hi all

    I'm banging my head on the wall with this one. I have a query that displays the result in the form of two columns, it works fine.

    I have a problem when I try to use "group"for the field DSC1 doesn't show duplicates."  He transforms the output in column 2, column 3 and column 4 spots white all along.

    Someone knows how can I get it to display 2 columns of output and does not show in double DSC1 fields? The following are examples of what is happening:


    1 example of what he does without group (note to Apple is twice, which is not):

    Apples apples

    Orange peaches

    banannas grapes

    What I need to do (only show each DSC1 once and continue with the format of two columns) :

    oranges apples

    Fisheries banannas

    grapes

    Here is the code I use:

    < cfquery name = "getProduct" datasource = "mydb" >
    SELECT * from ecitm
    WHERE DSC1 <>' '
    order by DSC1

    < / cfquery >

    <! - start the 2-column output table - >

    < table border = "0" width = "90%" border = "0" align = "center" cellpadding = "5" cellspacing = "5" >

    < cfset newrow = false

    < b >
    < cfoutput query = "getProduct" group = "DSC1" >

    < cfif newrow EQ "true" >
    < b >
    < / cfif >
    < td >
    #DSC1 #.
    < cfif DSC2 NEQ "" > "".
    < br >
    #DSC2 #.
    < / cfif >

    < br >
    < a href = "DetailsList.cfm? ID = #getProduct.ID # & litm = #getProduct.LITM #" > VIEW < /a > DETAILS
    < table >

    < cfif getProduct.currentRow MOD 2 EQ 0 >
    < /tr >
    < cfset newrow = true >
    < cfelse >
    < cfset newrow = false >
    < / cfif >


    < / cfoutput >
    < /tr >
    < /table >

    The currentRow always property will count the number or records in the record setting loop, if you their output or not.

    Since you are not the output values for each record in the Recordset, you must count the itterations yourself.

    Put a meter of itteration before the loop.

    Update the counter at the top of the loop.

    OR on newer versions of CF

    Reset the counter in the true clause of the block, where you also define new line. >

    Then use the variable in the iit instead the currentRow property to determine the number of items have been posted.

    **** OR ****

    You could do a simple SQL command does not get duplicates first and then use a loop of simple without any of the grouping and additional logic that you do.

    
    
    SELECT DISTINCT *
         FROM ecitm
         WHERE DSC1 <> ' '
         ORDER BY DSC1
    
    
    
    
         #DSC1#
         
    
        
    
    
    
  • using 'like' in the group record query

    Hello

    (Forms 6i)
    I dynamically create a record group.

    Then to when a new trigger for a list item.
    I want to list all the names of a table like 'a % ';

    query: select name, id (id) to_char of test_name where name like 'a % ';

    but I'm not able to give a quote unique in the query.
    Is it possible to do?

    Published by: Tuts009 on May 9, 2010 01:38

    In order to use it in this way:

    str := :list4||'%';
    rg_id := Create_Group_From_Query( rg_name,
                               'SELECT name,to_char(id) id from test_name where name like ''' || str || '''');
    
  • record group records

    How to count the records in the record group?

    Hello
    Get_Group_Row_Count is used to count the records in the record group.

    DECLARE
    RG_ID RecordGroup;
    status NUMBER;
    the_rowcount NUMBER;
    BEGIN
    RG_ID: = find_group ('emp');
    status: = Populate_Group ("emp");
         
         
    the_rowcount: = Get_Group_Row_Count (rg_id);
    MESSAGE (the_rowcount);
    end;

    better compliance
    skyniazi

  • Media Center will not register a particular channel, but all other records very well

    Hello, I can not Media Center to record a particular channel unless I am diverted listed steps below.  I get all the live channels.

    -the channel, I can't save is 30.1 in Memphis, TN (subsidiary CW) channel

    -My tuner: AVerMedia AVerMedia Duet - PCTV Tuner (A188 - white box) Interface PCI-Express x 1 MTVHDDUWB

    When I try to record a program at any time on channel 30, Media Center loses signal.

    While playing with it, I discovered that I can click to save while watching channel 30, then after that Media Center loses signal, follow these steps:

    Reach

    Settings/TV/TV Signal / Scan for multiple channels

    So, I have to empty the scanned channels and re-scan.

    Then it will start to record the channel 30.1.

    Help, please!  Why Media Center will not record 30.1 without all this trouble?

    Thank you

    Kris

    Go to settings-guide-add missing channels. Type in right channel # (like 8.1). Then put in the right frequency for the over-the-air station (35 in my case). You can find this info here (http://www.antennaweb.org/aw/welcome.aspx) if necessary. Now, you will have 2 channels in guide for 8.1 lists. Right-click on the new guide that lists you just create and go change the channel-edit lists. Change the source from the list to the channel that you have problems with. Next pass parameter-signal digital tv signal strength and a Coachman television that did not properly record to remove the Guide channel. This will fix your problem.

  • Group records in a Select statement

    I want to know, if I can do this with a single select:

    I have a table where I have some information with a collar-date:
    Column1  Column2  Column3  DateCol
    -------
    A        B        C        10/2001
    A        B        C        03/2001
    B        B        C        02/2001
    B        B        C        01/2001
    A        B        C        03/2000
    Now, I want to bring together the combination of col1-3, but in chronological order. This should be the result:
    Column1  Column2  Column3  DateCol
    -------
    A        B        C        10/2001
    B        B        C        02/2001
    A        B        C        03/2000
    Any ideas?

    Rumburak wrote:
    It is not a simple question group. Look at my example. The DateCol is the validity of a combination.

    If this is not a simple GROUP BY, then what is? Please explain what you are trying to do.
    That means each line of output represent?
    Why do you want 3 production lines and not 1 or 2, or 4 or 5?
    Why some production lines have distinct values in col1, col2 and col3, and others do not?

    It is possible that you wanted something like this:

    WITH     got_nums     AS
    (
         SELECT     col1, col2, col3
         ,     datecol
         ,     ROW_NUMBER () OVER ( PARTITION BY  col1, col2, col3
                                   ORDER BY          datecol
                           )                    AS group_num
         ,     ROW_NUMBER () OVER ( ORDER BY      datecol)     AS overall_num
         FROM     tbl
    )
    SELECT       col1, col2, col3
    ,       TO_CHAR ( MAX (datecol)
                  , 'MM/YYYY'
                )          AS datecol_month_year
    FROM       got_nums
    GROUP BY  col1, col2, col3
    ,            overall_num - group_num
    ORDER BY  MAX (datecol)               DESC
    ;
    

    but at least I understand the problem, I can only guess. Guess, this isn't a very effective way to work.

  • Using the function count with grouped records

    Hi all

    This seems like it should be very easy, but I still have to find a simple way to do it.

    Suppose I want to count the possibilities which are grouped by Sales Rep at run time I filter this list with a parameter for sales stage and created date.
    I've simplified this greatly, but here's what my setup looks like now:

    Sales representative*-Count* _
    <? for-each-group: opportunity [SalesStage = param1 and creation > param2]; /SalesRep? >
    <? SalesRep? >-<? count (current - group (available))? >
    <? end for each group -? >
    _ Total

    The only solution I have to get my grand total so far is to create a variable and permanently keep a total that I will then display in the Total column. It all works, it seems that there should be an easier way, want to do a simple count (Id) for a total general. But given that the Total amount will appear after the end of each group-, I lose the filter that has been applied to the group so that the count is not valid.

    Ideas of the experts?
    Thank you!

    To get the total general
    use

    param2]/Id)?>
    

    Since you have not mentioned the complete xml code, I assumed, as the root.
    If this isn't the case, put the full path from the root.

    If you give some xml examples and explain the output you want, we can fix it immediately.

    go through these too... something can be drawn from here.
    http://winrichman.blogspot.com/search/label/summation%20In%20BIP
    http://winrichman.blogspot.com/search/label/BIP%20Vertical%20sum

  • Oracle BI group records

    Hi all! I have a difficult situation when I'm BI project.
    I have the folder with 3 interactive dashboards. 2 it is hidden.
    When I see the top of my BI Windows I see the name of my file, and when I click on it in the menu I can change my dashboard only. But I need to see the name of the folder. I want to see the name of the dashboard immediately when a log on.
    More of him in my account dashboard hidden above the window, I see the name of the folder. And when I click on it nothing not.
    Please help me. He is very impotent for me.

    PS Sorry for my English.

    Fedor,

    Try to change the permissions on your dashboard. Give permission on the dashboard that you want the user to see when it connects will hide automatically other dashboards.

    -Red

  • Windows Search - Advanced 'modified files above 1 hour ago'

    Hello

    I'm doing what I think should be relatively easy, but is very difficult...

    Documentation refers to things like this:

    Relative dates: today, tomorrow, yesterday

    However, I would really like to be able to reduce it to 1 or two hours...

    I found a few tools that seem to be similar, but I did not "want to do something fancy so I figure why do I need YET ANOTHER utility to install and manage... but maybe that I don't - agentransak, astrogrep, all (voidtools)) some seem to have a format such as" # "that would be ideal (and intuitive?), but I can't find any doco and can't make it work with any combo I tried" "" , so I guess it just cannot be done.

    Tools for working with search in windows 7/8 don't seem to be that big... 8 seems to be better, but its still very obscure, what I can/cannot do with search...

    I searched in the XML code in the saved searches, but I don't really understand how his work and can't seem to get a lot more twisting the weird values (for example: R00UUUUUUUUZZXD-1NU... where THIS is documented.)

    the best that I've got so far is to use "changed: today" and the order of descending dateModified... but when there is a lot of activity, so sometimes it's a little slow...

    Any ideas/suggestions?

    Oh, for anyone to play with this stuff:

    • nice feature that I have not found in any of the doco... If you create a search and save and then select search and then add more to the search in the search and then save, it "refines" research... (Search IN THE SEARCH), it is somewhat impressive... too bad there isn't a GUI interface with that... maybe a massively underrated v. powerful feature!
    • Doesn't seem to be anything I can find which will restrict things for me at a time (always full of hope), but I found the following useful - it looks like you can save the view of folders with the research, so I did this, order by datemodified, group records as well as by type of file, to help me filter things and small practices , via the above 'cool' feature-, it appears (in the XML file that the searches are "booleanable" (so you can say "this AND this AND this OR this") and I managed to do is RELATIVELY fast (in some situations).)

Maybe you are looking for