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.

Tags: Database

Similar Questions

  • file lvm recorded with time stamp graphic display

    Hello

    I have headaches display my data with correct timestamp. There are so many methods to save the data. Here, I decided to save it in a text delimited as lvm. a screenshot of my vi segment is attached. I want to use this way rather than other methods is the flexibility it offers. I'll be able to add more data to store that I develop the vi. (So I'm storing data of the DAQ assistant and my calculated values.) I've attached a screenshot of the file I also read.

    I would use another vi to open this file and it draw a chart/graph to show a trend of the acquired data. Can someone pls Advisor mid on which is a better way for mi to do?

    Thank you very much!

    POH

    Hi Malou,

    Sorry for the late reply, I was rushing to complete my project, has not been able to answer.

    Yes, I managed to solve it. In any case, I've used this high rate in the acquisition of data wizard is to allow the acquisition of continuous mode & use a software filter instead of filter material. However writes to the folder this way - write string in .lvm, max is 10 samples/s unless I have use tdm (I'll then everything in the newspaper).

    I was not able to display the correct timestamp was due to the fact that I have does not add to the timestamp of the start time for the timestamp in waveform display. I won't be able to go down to my lab, & my machine have no LabVIEW, so what I do is to extract some parts of my report to share.

    For the part that I used to display the graph (can be seen on the attachment), I deleted the 1st column, which is the time stamp (for display of the spreadsheet), but extract the 1st element - convert timestamp DBL it when I start recording in the DAQ vi (written with the header).

    This excerpt (which could be considered as a group of numbers in the file lvm) and converted to the type timestamp and wired for generating waveform block, providing the start time of the wave.

    Then I replace the use of the chart with graphic, graphic is suitable for data acquired and graphic tracing is better for the time of execution of the data display. now it seems to work fine for me, except for the load time may take some time for larger files.

    Thank you for your participation in this thread!

    See you soon!

    POH

  • I want to record with &lt; alt &gt; &lt; s &gt; in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    Question
    I want to record with < alt > < s > in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    edit, escaped mod < s > in order to avoid the line through question

    A web page can be defined a "accesskey" for an item. Unlike IE/Chrome/Safari, who use the Alt key only, Firefox requires pressing Alt and Shift to activate the element. In other words, try

    ALT + SHIFT + S

    and see if it works.

    I don't know of any way to change this so that the change is not necessary. There may be an add-on?

  • How to call a form with splashing around by clicking on a record with a time where

    Hi all

    How to call a form with splashing around by clicking on a record with a time where clause. I mean when I dip, click current record I want to call another form with the details of the
    record with onetime where clause. Can someone help me in this regard.

    Now, I'll call you a form with parameter with where Jadi but this should be avoided.


    Thanks in advance

    Arif

    Maybe this helps http://andreas.weiden.orcl.over-blog.de/article-28180655.html

  • record in the table with time stamp

    Hello
    I use Forms6i and db 10g
    I have a datablock in my form, which is based on a table hlp_user_master.
    The table has fields crt_on, upd_on. who is date type.
    Now I'm set sysdate to these areas, before saving it to the database.
    He is now in the database, just.
    But I want it to be like date with the time.
    My Manager said to set the data type of the fields in the form.
    I did the DateTime data type, in the form
    but still in the database, just when saving

    Help, please

    Hello
    If you have changed in the form of the datetime data type and the mask format as I said in my previous post. Then, the database will have time also after saving it. I guess that you are checking in via SQL * more. If so, try the following query.

    SELECT TO_CHAR(DATE_COLUMN,'DD-MON-YY HH24:MI:SS');
    FROM TABLE_NAME;
    

    If the form is stalling as it will display then with time.

    -Clément

  • one-to-many selfjoin, delete records with the same rank or a substitution

    Sorry for my poor choice of the title of the discussion, feel free to suggest me a more relevant


    I rewrote for clarity and as a result of the FAQ post.


    Version of DB


    I use Oracle10g Enterprise 10.2.0.1.0 64-bit


    Tables involved

    CREATE TABLE wrhwr (
    wr_id INTEGER PRIMARY KEY,
    
    eq_id VARCHAR2(50) NULL,
    date_completed DATE NULL,
    status VARCHAR2(20) NOT NULL,
    pmp_id VARCHAR2(20) NOT NULL,
    description VARCHAR2(20) NULL);
    
    


    Examples of data


    INSERT into wrhwr  VALUES (1,'MI-EXT-0001',date'2013-07-16','Com','VER-EXC','Revisione')
    INSERT into wrhwr VALUES  (2,'MI-EXT-0001',date'2013-07-01','Com','VER-EXC','Verifica')
    INSERT into wrhwr  VALUES (3,'MI-EXT-0001',date'2013-06-15','Com','VER-EXC','Revisione')
    INSERT into wrhwr  VALUES (4,'MI-EXT-0001',date'2013-06-25','Com','VER-EXC','Verifica')
    INSERT into wrhwr  VALUES (5,'MI-EXT-0001',date'2013-04-14','Com','VER-EXC','Revisione')
    INSERT into wrhwr  VALUES (6,'MI-EXT-0001',date'2013-04-30','Com','VER-EXC','Verifica')
    INSERT into wrhwr  VALUES (7,'MI-EXT-0001',date'2013-03-14','Com','VER-EXC','Collaudo')
    
    


    Query used

    SELECT *
      FROM (SELECT eq_id,
                   date_completed,
                   RANK ()
                   OVER (PARTITION BY eq_id
                         ORDER BY date_completed DESC NULLS LAST)
                      rn
              FROM wrhwr
             WHERE     status != 'S'
                   AND pmp_id LIKE 'VER-EX%'
                   AND description LIKE '%Verifica%') table1,
           (SELECT eq_id,
                   date_completed,       
                   RANK ()
                   OVER (PARTITION BY eq_id
                         ORDER BY date_completed DESC NULLS LAST)
                      rn
              FROM wrhwr
             WHERE     status != 'S'
                   AND pmp_id LIKE 'VER-EX%'
                   AND description LIKE '%Revisione%') table2,
           (SELECT eq_id,
                   date_completed,            
                   RANK ()
                   OVER (PARTITION BY eq_id
                         ORDER BY date_completed DESC NULLS LAST)
                      rn
              FROM wrhwr
             WHERE     status != 'S'
                   AND pmp_id LIKE 'VER-EX%'
                   AND description LIKE '%Collaudo%') table3
     WHERE     table1.eq_id = table3.eq_id
           AND table2.eq_id = table3.eq_id
           AND table1.eq_id = table2.eq_id
    
    

    The above query is intended to selfjoin wrhwr table 3 times in order to have for each line:

    • eq_id;
    • date of the completion of a verification type work request for this eq_id (aka table1);
    • date completion of a line (aka table2) type wr for this eq_id;
    • date of completion of a type wr Collaudo (aka table3) for this eq_id;

    A separate eq_id:

    • can have different completion of many requests for work (wrhwr records) with dates or date of completion (date_completed NULL column).
    • in a date range can have all types of wrhwr ('verification', 'Line', 'Problem'), or some of them (e.g. audit, line but not Collaudo, Collaudo but not verification and line, etc.);
    • must not repeat the substrings in the description;
    • (eq_id, date_completed) are not unique but (eq_id, date_completed, description, pmp_id) must be unique;

    Expected results

    Using data from the example above, I expect this output:

    eq_id, table1.date_completed, table2.date_completed, table3.date_completed

    MI-ext-001,2013-07-01,2013-07-16,2013-03-14 <- to this eq_id table3 doesn't have 3 lines but only 1. I would like to repeat the value most in the rankings in table 3 for each line of output

    MI-ext-001,2013-07-01,2013-06-15,2013-03-14 <-I don't want this line of table1 and table2 with both 3 lines match must be in terms of grade (1st, 1st) (2nd, 2nd) (3rd, 3rd)

    MI-ext-001,2013-06-25,2013-06-15,2013-03-14 <-2nd table1 joined the 2nd row from table2

    MI-ext-001,2013-04-30,2013-04-14, 2013-03-14 <-1 table1, table2 rank rank 1, 1st rank table3

    In the syntax of vector style, tuple expected output should be:

    IX = ranking of the i - th of tableX

    (i1, i2, i3) IF EXISTS a rank i - th line in each table

    ON THE OTHER

    (i1, b, b)

    where b is the first available lower ranking of the table2, or NULL if there isn't any line of lower rank.

    Clues?

    With the query, I am unable to delete the lines "spurius.

    I think a solution based on analytical functions such as LAG() and LEAD(), using ROLLUP() or CUBE(), using nested queries, but I would find a solution elegant, simple, fast, and easy to maintain.


    Thank you

    Hello

    Sorry, it's still not quite clear what you are asking.

    This becomes the desired resutls of the sample data you posted:

    WITH got_r_type AS

    (

    SELECT eq_id, date_completed

    CASE

    Description WHEN LIKE '% Collaudo %' THEN 'C '.

    Description WHEN AS 'Line %' THEN 'R '.

    Description WHEN AS 'Verification %' THEN 'V '.

    END AS r_type

    OF wrhwr

    Situation WHERE! = s "

    AND pmp_id LIKE '% WORM - EX'

    )

    got_r_num AS

    (

    SELECT eq_id, date_completed, r_type

    , ROW_NUMBER () OVER (PARTITION BY eq_id, r_type)

    ORDER BY date_completed DESC NULLS LAST

    ) AS r_num

    OF got_r_type

    WHERE r_type IS NOT NULL

    )

    SELECT eq_id

    LAST_VALUE (MIN (CASE WHEN r_type THEN date_completed END = ' V')

    IGNORES NULL VALUES

    ) OVER (PARTITION BY eq_id

    ORDER BY r_num

    ) AS audit

    LAST_VALUE (MIN (CASE WHEN r_type = 'R' THEN date_completed END)

    IGNORES NULL VALUES

    ) OVER (PARTITION BY eq_id

    ORDER BY r_num

    ) AS line

    LAST_VALUE (MIN (CASE WHEN r_type = 'C' THEN date_completed END)

    IGNORES NULL VALUES

    ) OVER (PARTITION BY eq_id

    ORDER BY r_num

    ) AS collauda

    OF got_r_num

    GROUP BY eq_id

    r_num

    ORDER BY eq_id

    r_num

    ;

    I guess the description can have (at most) only substrings target, in other words, you can't have a line like this:

    INSERT into (1,'MI-EXT-0001',date'2013-07-16','Com','VER-EXC','Revisione VALUES wrhwr and audit");

    In addition, you said the combination (eq_id, date_comepleted) is not unique, that it is y no example of this in your sample data.  What results would you if, in addition to this line (who did the validation):

    INSERT into wrhwr VALUES (7,'MI-EXT-0001',date'2013-03-14','Com','VER-EXC','Collaudo');

    the following line is also?

    INSERT into wrhwr VALUES (97,'MI-EXT-0001',date'2013-03-14','Com','VER-EXCFUBAR','Collaudo');

    .

    You could do a self-join instead of GROUP BY, but I suspect it will be much less effective.  You can use FULL OUTER JOIN, since you do not know what r_types was that r_nums.

  • Problem saving 2 Macbook Pro with Time Machine

    Hi all

    I changed my Macbook a year ago and I want to record to Time Machine. I would use the same external drive for both (1).

    However, both my computer with the same name. I tried to change the name of my second Macbook. But when I changed and used Time Machine, he changed the name of the first Macbook and registered under the same name as if I used only one. I stopped recording, I'm afraid I lost my previous laptop data.

    Someone has any idea how should I proceed?

    Thank you!

    Thiebaud

    If the external hard drive is connected to the computer, try partitioning the drive into 2 partitions. Put a backup on each partition.

    Open utility disk, select your hard drive (step 1), then the partition (step 2) tab and select the partition. Using of the / / / to the low blow it upwards (step 3) until the box the size decreases by about 50 GB. Select the newly created space and press the button (step 4). Name it something and choose Mac OS extended (journaled) format (step 5). Then click on the button apply (step 6). Download the installation program from the App Store and when it starts, point it to the new partition. You can make a copy of the installer out of the Applications folder to avoid having to re - download in the future. Once installed, reboot with the option/alt key is pressed, select the new partition and restart. Test now.

  • I can't get my new WD external hard drive to work with Time Machine.

    My Seagate 1 TB external hard drive, connected to my Airport Extreme, use the USB port, was completed (it stores up to 3 1 iMac and MBP), so I bought a Western Digital 2 TB hard drive to replace it. I formatted correctly, connected to my MBP, then connected to the Airport Extreme. When I opened the time Machine, it didn't appear. By selecting "Set up the new TimeCapsule" open Airport utility. By clicking on the router button gave me change. By clicking on the "Record" button showed my new hard drive. The "setup" button is grayed out, unless I unchecked and double-checked all of the options. He warned me that I would be offline for a while, but it did nothing; My wife MBP and MBP my son not a never lose their connection to the internet, and I lose mine, either.

    My Mac guy, who never met a problem he couldn't fix it, is puzzled. So I am. We tried all the usual ideas, restart my MBP, restart the Airport Extreme, reformat the external hard drive, with different numbers of partitions (and Yes, I chose the GUID), but we can not simply Time Machine to connect with the hard drive. It is a Western Digital My Passport Ultra. This external hard drive is not compatible with Time Machine?

    What version is your AE? Backup is supported only on the sector of Tower model.

    You are self feeding Ultra Passport? It really must be external powered... or plugged into a powered hub.

    My passport readers have been consistent in the past... but sometimes strange things... That is, they can change the USB chip without warning, resulting in questions. The USB hub can help.

    There is also something... Plug the USB key into one of your computers and start backup TM on this... proceed very long... but we need to start... Cancel backup... and then plug it into AE and see what happens.

  • How can I get the clips in record full-time instead of the 25seconds (which seems to be set) when using windows DVD maker

    How can I get the clips in record full-time instead of 25 seconds (that they seem to be defined) using windows DVD maker

    Hi LorraineDawson,

    Here's a walkthough troubleshooting on this issue:

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-creating-a-DVD-video-using-Windows-DVD-Maker

    hope this helps

    B Eddie

  • 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

  • Error recovery DB TIMESTAMP WITH time ZONE SCHEDULE

    I use Managed Driver version 4.121.1.0 with EF. Trying to extract data from a table that contains a column what data type is TIMESTAMP WITH time ZONE SCHEDULE, I get a "System.InvalidTimeZoneException" in Oracle.ManagedDataAccess.dll.

    This is the statement that I'm executing:

    application of var = db. COORDENADA. Select (x = > new {ID = x.COORDENADAID, CREATED = x.FECHAHORAGPS}). ToList();

    var RES = query. ToList();

    When debugging of I am, I can see the SQL to run:

    SELECT

    "Extent1". "" COORDENADAID "AS"COORDENADAID. "

    "Extent1". "' FECHAHORAGPS ' AS 'FECHAHORAGPS '.

    OF "GEOTRACKER. "" COORDENADA ""Extent1 ".

    which causes no problem in Oracle SQL Developer and get these data:

    COORDENADAID FECHAHORAGPS

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

    1 06/03/14 17:10:10, EUROPE 000000000

    / PARIS

    2 02/03/14 00:00:00, 000000000 EUROPE

    / PARIS

    ...

    I think there must be something with the time format returned as name instead of offset, but I can't understand how to check this. Any idea

    This bug has been fixed in Oracle DB 12.1.0.1.6 patch bundle which can be downloaded from My Oracle Support (MOS). After you download the patch bundle, you'll notice that it's a pretty important download. There is no need to install the patch to the entire group on your target computer. Instead, simply extract the managed provider and just install it.

    If you do not have access to MOS, ask your DBA that should, or you can wait for the next version of the ODAC for the fix.

  • 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. :)

  • I can plan a recording with P.P.?

    I want to plan a recording with P.P.

    I try and test Virtual dub with VCR virtual for that to work, but the result isn't digestive Adobe P.P.

    Some of you know a plugin or a method for recording time preset with P.P.

    I apologize now for my English

    Bill,

    It's also pretty well my view on things. Your comment about DV - AVI Type II will be useful to the Miko.

    Miko,.

    With regard to planning PrPro to make a direct capture of virtual VCR, that won't be possible, but if it allow to save/export to DV - AVI Type II, is just a click to import this / these resulting files in PrPro, just as Bill describes. PrPro cannot be foreseen, such as a VCR or DVR, but once your other software has done its job, the rest is easy.

    Good luck

    Hunt

    Post edited by: the_wine_snob - spell

  • 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.

  • Can Notes show the number of records with each folder?

    Can Notes show the number of records with each folder?

    No it can't. It would be nice tho.

Maybe you are looking for

  • How can I change the screen to the original screen?

    Use Firefox for months with screen full page on my laptop when all of a sudden it changed to a split screen while I was on a site of games AARP and it stays that way now - making it useless by cutting pertinent information when I search for other sit

  • The create a System Image will save the FPGA code and the RT code?

    I have some cRIO systems which were broadcast in our manufacturing plant for some time. A slight problem has been discovered in the programming and created a workaround solution, but a fix should be implemented. Currently, I have no way to test my ne

  • CCC for my HP Envy m6-1231ea

    Where can I download for my HP Envy CCC m6-1231ea lately because I had a lot of problems with the CCC and not being only unable to use switchable graphics that makes the fps on games I play fall dramatically. Please answer as soon as POSSIBLE, and it

  • Display problem list in bb10 Beta 3

    Hello I develop a project in the bb10. His work properly in the beta version of bb10 2. Now I am this conversion to bb10 beta version 3. In that I have a list view. IE filtered list view. When header is clicked, the child must be visible. I had used

  • Bandwidth - 2921

    Nice day I would limit the amout of its use on one of my subnets. I have 10.20.60.0, 192.168.20 - voice, 10.20.50.0 How can set my 10.20.50.0 subnet to use as 1%, or simply limit to 1? Hope I'm making sense.,.