Question for analytic functions experts

Hi,
I have an ugly table containing an implicit master detail relation.
The table can be ordered by sequence and then each detail is beneath it's master (in sequence).
If it is a detail, the master column is NULL and vice versa.
Sample:
SEQUENCE MASTER DETAIL BOTH_PRIMARY_KEYS
1____________A______________1
2___________________A_______1
3___________________B_______2
4____________B______________2
5___________________A_______3
6___________________B_______4
Task: Go into the table with the primary key of my detail, and search the primary key of it's master.
I already have a solution how to get it, but I would like to know if there is an analytic statement,
which is more elegant, instead of selfreferencing my table three times. Somebody used to analytic functions?
Thanks,
Dirk

Hi,
Do you mean like this?
with data as (
select 1 sequence, 'A' master, null detail, 1 both_primary_keys from dual union all
select 2, null, 'A', 1 from dual union all
select 3, null, 'B', 2 from dual union all
select 4, 'B', null, 2 from dual union all
select 5, null, 'A', 3 from dual union all
select 6, null, 'B', 4 from dual )
select (select max(both_primary_keys) keep (dense_rank last order by sequence)
        from data
        where sequence < detail_record.sequence and detail is null) master_primary_key
from data detail_record
where (both_primary_keys=3 /*lookup detail key 3 */  and master is null)

Similar Messages

  • Alternate for analytic functions

    Hello All,
    I'm trying to write a query without using analytic functions.
    Using Analytic func,
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE     11.2.0.2.0     Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    SELECT id, sal, rank() OVER (PARTITION BY ID ORDER BY SAL) rnk FROM
    (SELECT 10 AS id, 100 AS sal FROM DUAL
        UNION ALL
        SELECT 10, 300 FROM DUAL
        UNION ALL
        SELECT 10, 400 FROM DUAL
        UNION ALL
        SELECT 20, 200 FROM DUAL
        UNION ALL
        SELECT 20, 200 FROM DUAL
        UNION ALL
        SELECT 20, 300 FROM DUAL
        UNION ALL
        SELECT 30, 100 FROM DUAL
        UNION ALL
        SELECT 40, 100 FROM DUAL
        UNION ALL
        SELECT 40, 200 FROM DUAL
        ) Expected results. I want these results without analytic functions.
    10     100     1
    10     300     2
    10     400     3
    20     200     1
    20     200     1
    20     300     3
    30     100     1
    40     100     1
    40     200     2

    Hi,
    SamFisher wrote:
    Thank You Frank. That was simple.
    I was trying to get the reults without using analytical functions. Just trying to improve my SQL skills. Yes, I admit that practicising using the wrong tools can improve your SQL skills, but I think there's a lot to be said for practising using the right tools, too.
    I tried all sort of things. I thought hierarchical query would do it but hard luck for me.Do you want to use a CONNECT BY query for this? Here's one way:
    WITH     got_max_level            AS
         SELECT       id
         ,       sal
         ,       MAX (LEVEL)     AS max_level
         FROM       table_x
         CONNECT BY NOCYCLE  id        = PRIOR id
              AND          sal       >= PRIOR sal
              AND     (   sal       >  PRIOR sal
                   OR  ROWID > PRIOR ROWID
         GROUP BY  id
         ,            sal
    ,     got_cnt          AS
         SELECT       id
         ,       sal
         ,       COUNT (*)     AS cnt
         FROM       table_x
         GROUP BY  id
         ,            sal
    SELECT       x.id
    ,       x.sal
    ,       l.max_level + 1 - c.cnt     AS rnk
    FROM       table_x        x
    JOIN       got_max_level  l  ON   x.id     = l.id
                         AND      x.sal     = l.sal
    JOIN       got_cnt      c  ON      x.id     = c.id
                         AND      x.sal     = c.sal
    ORDER BY  x.id
    ,            x.sal
    ;This is even less efficient, as well as more complicated, than the scalar sub-query solution.

  • Yet another question on analytical functions

    Hi,
    A "simple" issue with date overlapping: I need to display a "y" or "n" where a start time/end time overlaps with another row for the same employee.
    For this, I used analytical functions to find out which rows were overlapping. This is what I did:
    create table test (id number, emp_id number, date_worked date, start_time date, end_time date);
    insert into test values (1, 333, to_date('2008-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 10:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    insert into test values (2, 333, to_date('2008-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 10:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    insert into test values (3, 444, to_date('2008-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 09:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    insert into test values (4, 333, to_date('2008-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 13:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    SQL> select * from test;
            ID     EMP_ID DATE_WORKED         START_TIME          END_TIME
             1        333 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 10:00:00 
             2        333 01-01-2008 00:00:00 01-01-2008 10:00:00 01-01-2008 12:00:00  --> conflict
             3        444 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 09:00:00
             4        333 01-01-2008 00:00:00 01-01-2008 11:00:00 01-01-2008 13:00:00  --> conflict Here I see that Employee 333 is scheduled from 10 to 12 am, but it's also scheduled from 11 to 13. This is a conflict.
    To find this conflict, I did this (please correct me if this is incorrect):
    SQL> select id, emp_id, date_worked, start_time, end_time, next_date
      2  from (
      3        select lead( start_time, 1 ) over ( partition by emp_id order by start_time ) next_date,
      4               start_time, end_time, emp_id, date_worked, id
      5        from   test
      6       )
      7  where  next_date < end_time;
            ID     EMP_ID DATE_WORKED         START_TIME          END_TIME            NEXT_DATE
             2        333 01-01-2008 00:00:00 01-01-2008 10:00:00 01-01-2008 12:00:00 01-01-2008 11:00:00So far, so good. Where I'm stuck is, I need to display the conflicts in this way:
            ID     EMP_ID DATE_WORKED         START_TIME          END_TIME            OVERLAPPED
             1        333 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 10:00:00
             2        333 01-01-2008 00:00:00 01-01-2008 10:00:00 01-01-2008 12:00:00 yes
             3        444 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 09:00:00
             4        333 01-01-2008 00:00:00 01-01-2008 11:00:00 01-01-2008 13:00:00 yes Is there a way I can achieve this?
    I tried doing a nested query with a count(*) but no success...

    I found an issue. Say we insert this row.
    insert into test values (5, 333, to_date('2008-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 07:00:00', 'YYYY-MM-DD HH24:MI:SS'),to_date('2008-01-01 08:00:00', 'YYYY-MM-DD HH24:MI:SS'));
    SQL> select * from test order by start_time;
            ID     EMP_ID DATE_WORKED         START_TIME          END_TIME
             5        333 01-01-2008 00:00:00 01-01-2008 07:00:00 01-01-2008 08:00:00
             1        333 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 10:00:00
             3        444 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 09:00:00
             2        333 01-01-2008 00:00:00 01-01-2008 10:00:00 01-01-2008 12:00:00 --> conflict
             4        333 01-01-2008 00:00:00 01-01-2008 11:00:00 01-01-2008 13:00:00 --> conflictIf I run the SQL suggested by Nicloei, I get:
    SQL> select id,
      2         emp_id,
      3         date_worked,
      4         start_time,
      5         end_time,
      6           Case When end_time > prev_date Or next_date > End_time Then 'Yes' Else 'No' End over_lap
      7      from (
      8            select lead( start_time, 1 ) over ( partition by emp_id order by start_time ) next_date,
      9                   lag( start_time, 1 ) over ( partition by emp_id order by start_time ) prev_date,
    10                   start_time, end_time, emp_id, date_worked, id
    11            from   test
    12           );
            ID     EMP_ID DATE_WORKED         START_TIME          END_TIME            OVER_LAP
             5        333 01-01-2008 00:00:00 01-01-2008 07:00:00 01-01-2008 08:00:00 No
             1        333 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 10:00:00 Yes
             2        333 01-01-2008 00:00:00 01-01-2008 10:00:00 01-01-2008 12:00:00 Yes
             4        333 01-01-2008 00:00:00 01-01-2008 11:00:00 01-01-2008 13:00:00 Yes
             3        444 01-01-2008 00:00:00 01-01-2008 08:00:00 01-01-2008 09:00:00 NoIt's basically saying that there's an overlap between id 1 and id 2 (8-10 and 10-12), which is incorrect. I ran the inner query by itself:
    SQL> select lead( start_time, 1 ) over ( partition by emp_id order by start_time ) next_date,
      2                   lag( start_time, 1 ) over ( partition by emp_id order by start_time ) prev_date,
      3                   start_time, end_time, emp_id, date_worked, id
      4            from   test;
    NEXT_DATE           PREV_DATE           START_TIME          END_TIME                EMP_ID DATE_WORKED                 ID
    01-01-2008 08:00:00                     01-01-2008 07:00:00 01-01-2008 08:00:00        333 01-01-2008 00:00:00          5
    01-01-2008 10:00:00 01-01-2008 07:00:00 01-01-2008 08:00:00 01-01-2008 10:00:00        333 01-01-2008 00:00:00          1
    01-01-2008 11:00:00 01-01-2008 08:00:00 01-01-2008 10:00:00 01-01-2008 12:00:00        333 01-01-2008 00:00:00          2
                        01-01-2008 10:00:00 01-01-2008 11:00:00 01-01-2008 13:00:00        333 01-01-2008 00:00:00          4
                                            01-01-2008 08:00:00 01-01-2008 09:00:00        444 01-01-2008 00:00:00          3with this data, I can't seem to find a way to conditional test in order to print my overlap column with "yes" or "no" accordingly.
    am I missing something?

  • 2.1 EA Bug: group by auto complete generates group by for analytic function

    Hi,
    when using an analytic function in the sql text, sqldeveloper generates an automatic group by statement in the sql text.
    Regards,
    Ingo

    Personally, I don't want anything changed automatically EVER. The day you don't notice and you run a wrong statement, the consequences may be very costly (read: disaster).
    Can this be turned off all together? If there's a preference I didn't find, can this be left off by default?
    Thanks,
    K.

  • Looking for Financials Functional Expert - $100/Hr + Contract Opportunity

    Our company has been looking for Oracle Financials functional consultants who have implemented the below modules for other organizations - iReceivables, iPayables, Adv. Collections and LockBox
    This is an existing EBS installation with A/R already implemented. We need an expert who can help us implement the above new modules.
    Pl. respond with resume and contact info to [email protected]
    Thanks

    Hi sir,
    I am currently working in a MNC, as an engineer. I am keenly interested in Labview, and i know basics of it.
    Attached is my resume. I would like to work with Labview.
    Regards,
    Pooja karnani
    Attachments:
    RESUME.docx ‏30 KB

  • Question for you Apple experts

    First let me state that I don't mean this to be a ******** session. I bought my Iphone in December and overall I'm pleased. It doesn't run my life, I use it to make and receive calls and email. With the exception that one day it turned into a brick, 2.0 update, things have worked rather well. What troubles me is that so many people have so many problems. Now I realize that reading this forum is like going into a hospital, everyone is sick. And being tech. challenged I don't know how these things work, but seems to me that a company like Apple being in the business for some years should be able to put out updates that don't cause so many to have such problems. Is it a problem with testing, rushing the product to market to keep ahead of the competition, or are many of these issues the fault of the user?
    Or are these machines so complicated that no matter what preparation is undertaken, mass casualties will occur?
    You folks tell me.

    I have been an Apple user for many years and in that time I have had a few problems but not too many. This iPhone update is a pretty rare occurrence but sometimes things happen. I used to NEVER update my software until several weeks after an update came out for just this very reason but lost my mind in anticipation of 2.0. I wont be doing that again. I also turn OFF automatic updates for this reason. A mission critical piece of hardware should only be updated when it is absolutely certain it is safe...this includes your phone. I just wish there was an easier way to back up your iPhone like you can your computer. If I run an update to OSX and it hoses my system I just restore it from the backup disk image I created just BEFORE I ran the update. The iPhone won't let you do this and that's bad.
    Why did they release 2.0 AND 3G on the same day? If everybody downloaded the 2.0 update several days BEFORE the 3G came out and discovered they could have 90%+ of the functionality and NOT have to buy a new phone, do you think they would have sold over 1 Million units the first weekend? If they released 2.0 a few days after the 3G launch the Apple community WHINE would be overwhelming. So they chose the lesser of the two evils I guess.
    Apple is VERY secretive of it's hardware and software and I'm sure they try to test it as best they can but sometimes you can only do what you can do. Out of the millions of Original iPhone users out there, statistically speaking this isn't "too" bad, but I had to exchange my iPhone for another because it was so terrible and you can bet I won't try to update it again until there is a better confirmation on the 2.0.1. I learned my lesson. Apple however very graciously replaced my iPhone and I am happier for it.
    And NO, I didn't update it from the rumor sites link. I ran the update from iTunes as any SANE person would. If you downloaded and installed an update from an unofficial link you don't have any right to complain that you screwed your phone.

  • Simple question for deterministic functions

    It is written in oracle documents about deterministic functions:
    "Indicates that the function returns the same result value whenever it is called with the same values for its parameters."
    I am wondering is it cached? or is it performing in run time?
    for example when we execute a sql stement just one time and if we execute it again will the deterministic function performed?

    I am wondering is it cached? or is it performing in run time?
    PL/SQL Subprograms
    If result caching is enabled and the function was already called before with the same parameter value(s) (implying the result was cached) then the cached result gets returned (if still in the cache) without running the function code to compute the result.
    Regards
    Etbin

  • Postage Stamp question for you Stamp experts

    Purchased some bulk mint  postage locally.   In the lot was a number of Stamps with the red Maple Leaf and just the letter  "A". I remember these way back when.  I know that they had a fixed value but can not remember the exact value.  I asked at the local PO but had a new person on and they didn't have a clueThanks all

    recped wrote:
    International or USA or Packages______________________________________________________________________________________ Haha!  Those of us who are over 50 had this answer right at hand!  I guess I've just dated myself   It's amazing how knowledge of the simple answer to such things can be lost in a generation or two.  Actually 'zeechan's' question reminded me of an incident that occurred about 10 years ago in an office where I was working.  The office manager asked a young student who was doing "odd jobs" for the firm for the summer to clean out the fridge in the lunchroom.  The student took one look at the fridge, then ran back to the manager to say:  "There's ice everywhere inside -- how do I get that out?!"   Need I add for those of us over 50, that the fridge was not frost-free, and the student was instructed to simply unplug it and wait to clean up the remains of the ice.  Oh, right.  In the same vein, it makes me wonder whether all those fine old colourful sayings in English about the lowly penny will make no sense ("cents"?? LOL) to anyone under 20 in a couple of decades.  A penny for your thoughts?  Pennies from heaven?  Penny wise but pound foolish?  Penny candy?  Cost a pretty penny? Penny ante? Spend a penny? Penny-pincher?  Turn up like a bad penny? The penny dropped?, etc. etc. etc. Huhhh?? OK, sorry, now I'm babbling...  

  • New iMac-Questions for musicians/computer experts

    Friends,
    My primary reason for buying a new iMac has to do with home music recordings. (Especially w GarageBand, but other music programs as well.)
    Spent the day trying to get things going with my brand new iMac. (Specs below).
    Things went pretty well, except when I got to peripherals. So, for some of you musicians out there who might have encountered similar situations when upgrading computers/operating systems:
    1) *Presonus Firebox* preamp. On my old iMac, all I would do was plug in the firewire to the computer and the preamp turned on. (Usually left the firewire plug into the preamp all the time.) Never used the AC adaptor. Apparently wasn't necessary. The cable was a 6-pin to 6-pin. (Meaning, I think, 400 to 400.)
    a) Tried to get the preamp going on the "new" iMac. Used a new 6-pin, coming out of the PreSonus Firebox, to 9-pin, going into the new iMac firewire port, cable. Nothing happened. Firebox didn't turn on.
    b) Thoughts? Why didn't it work? Do I need to go to the PreSonus Firebox web-page to download an updated driver that will work with +Snow Leopard+? (Been to that site and it said +Mac users do not need to do this+.)
    c) This is critical for me. I don't want to by a new preamp to do my recordings.
    2) *Yamaha DGX-305* keyboard/synthesizer. I've used this for many recording purposes...sole piano work, comping, effects, etc... bringing it in as either MIDI (via USB cable) or analog (headphone out to iMac audio line in). But...
    a) when I tried to bring it into my new iMac (same way: USB cable for MIDI), nothing happened. Tried to record....settings were all the same as on the old Mac (i.e. to a MIDI track in GB, line in/out were correct after setting them on the computer)....pushed "record" button, played, marker/track moved, but nothing was recorded.
    b) It would seem that I would have to go to the Yamaha web site to download the latest driver to make this work.
    Following a visit to the HP site and a phone call, was told that HP stopped making the printer I have (about six years old) and, therefore, do not make drivers compatible with +Snow Leopard+. So, today, I purchased a brand new printer. Certainly did not think I would have to do that after buying a new computer. And wasn't particularly happy about it. Present printer works just fine.
    I will be visiting the websites and calling +PreSonus Firebox+ and Yamaha tomorrow morning to inquire about workable updated drivers for +Snow Leopard+. My great fear is that either or both will say the same thing as HP: "Stopped making those models and do not have downloadable drivers" for my new computer/operating system.
    If that would be the case, it would mean that the "critical" peripherals for my home music recordings would be obsolete. Effectively negating the usefulness of my brand new iMac.
    *THE MAIN CONCERN:*
    *I do not want to buy a new preamp, keyboard, or whatever to enable me to resume my recording efforts. I didn't sign up for that when I bought my new iMac.*
    Anxiously awaiting your thoughts.
    The only reason I bought a new iMac (the old one...which I will still keep, works perfectly fine, just pushed to capacity) was to make my home recording efforts easier. Meaning, less stress on the processor, more space available on the computer itself for those huge music files, and more speed with much more RAM.
    But it never occurred to me that buying a new computer would require buying everything else to go with it: printer, preamp, keyboard, etc.
    And, just a quick p.s. regarding GB: on the old version I have, GB2, when you double-clicked the "instrument" icon at the very left of the track, it brought up a window where you could adjust things, change instrument sound/audio font, turn monitor on/off etc. However, when I double-clicked the instrument icon on the new GB, nothing happened. It would seem this is a typical problem with updated programs. Nothing, or at least not enough, is where it used to be. A real problem for an old guy like me to re-learn everything. I'm sure I'll have to do a lot more exploring to find out how this new GarageBand works.
    Thanks for any comments/suggestions. (If it weren't for the invaluable resource of Apple Discussion Forums, I wouldn't even have considered buying a new computer. At least I know you guys are here.)

    • Firebox: There is a problem with the Firewire card in newer Macs - I have the same problem. It will not sync up with some interfaces (I have the Inspire) when they have no external power source. There's only two solutions: use the power adaptor, or chain it with an externally powered hard drive. After everything is up and running, it should be okay to unplug the power adaptor.
    • Keyboard: The device that your computer is connected to is not the keyboard but the midi interface (which you call "cable"). You can plug any midi instrument into that, the Mac doesn't care. So you'll have to update your interface's driver, but you don't tell us what it is. If it's a yamaha intereface:
    http://www.global.yamaha.com/download/usb_midi/
    (And a note: Lengthy posts like yours, with a lot of talk about why you bought your computer etc., don't attract a lot of people to give you answers. A short but concise description of your problem - like what interface you are using - is a lot more helpful.)

  • Question about analytic function

    I have a table (t1) that contains text (source_ip) and a corresponding number column (attack_count). I'm trying to group source_ip, sum attack_count per unique source ip, and then provide a percentage for unique source_ip attack count to the total sum of attack count.
    For example (t1):
    source_ip attack_count
    text1 5
    text2 4
    text1 1
    My output would (should) look like:
    col.a col.b col.c
    text1 6 60.00
    text2 4 40.00
    This is what I've come up with so far:
    SELECT a.source_ip, ROUND(SUM(a.attack_count)/b.total_attack*100, 2) PERCENTAGE, sum(attack_count)
    FROM t1 a, (SELECT sum(attack_count) total_attack FROM t1) b
    where time between '01-AUG-05' and '01-SEP-05'
    GROUP BY a.source_ip, b.total_attack
    order by PERCENTAGE DESC
    The query runs, groups source_ip, and sums(attack_count) just fine but provides an invalid percentage. I can't quite figure out where I'm going wrong.
    Any ideas? Thanks!

    test@orcl> create table attacks ( source_ip varchar2(15), attack_count number );
    Table created.
    Elapsed: 00:00:00.09
    test@orcl> insert into attacks values ( 'text1', 5 );
    1 row created.
    Elapsed: 00:00:00.00
    test@orcl> insert into attacks values ( 'text2', 4 );
    1 row created.
    test@orcl> insert into attacks values ( 'text1', 1 );
    1 row created.
    test@orcl> commit;
    Commit complete.
    -- option1:
    test@orcl> select source_ip,
    2 sum(attack_count) sum_attack_count,
    3 round(sum(attack_count)/max(t.tot)*100,2) percent
    4 from attacks, ( select sum(attack_count) tot from attacks ) t
    5 group by source_ip
    6 order by percent desc;
    SOURCE_IP SUM_ATTACK_COUNT PERCENT
    text1 6 60
    text2 4 40
    2 rows selected.
    -- option2:
    test@orcl> select source_ip,
    2 sum_attack_count,
    3 round((sum_attack_count/sum(sum_attack_count) over ())*100, 2) per
    4 from
    5 (
    6 select source_ip,
    7 sum(attack_count) sum_attack_count
    8 from attacks
    9 group by source_ip
    10 )
    11 order by per desc;
    SOURCE_IP SUM_ATTACK_COUNT PER
    text1 6 60
    text2 4 40

  • Question For The WPA Experts

    I currently have a WRT54G on a home network.  I am using WEP.  This is convenient for guests with laptops as they simply need the key and SSID.  If the network is changed to WPA will things remain as convenient?  I don't understand how the rotating key would work with a newcomer after several itterations.  Thanks.

    just an added info:  
    when some adapters or the softwares of such adapters don't support the wpa, what you can try to do is to update the software or use a windows xp service pack 2. If your PC comes with service pack 1, you just need to update that to the service pack 2...
    "a helping hand in a community makes the world a universe"

  • Looking for Analytical function to filter query

    Source dataset for one of policy
    PC_COVKEY     POLICY_NUMBER     TERM_IDENT     COVERAGE_NUMBER     TRANSACTION_TYPE     COV_CHG_EFF_DATE     TIMESTAMP_ENTERED
    10897523P7013MC0010072     10897523P7     013     001     10     17/NOV/2008     20/NOV/2008 05:36:45.482025 PM
    10897523P7013MR0030062     10897523P7     013     003     10     17/NOV/2008     20/NOV/2008 05:36:45.514349 PM
    10897523P7013MC0010062     10897523P7     013     001     03     20/NOV/2008     20/NOV/2008 05:26:13.205097 PM
    10897523P7013MR0030052     10897523P7     013     003     03     20/NOV/2008     20/NOV/2008 05:26:42.587605 PM
    10897523P7013MC0010082     10897523P7     013     001     07     20/NOV/2008     20/NOV/2008 05:36:51.605820 PM
    10897523P7013MR0030072     10897523P7     013     003     07     20/NOV/2008     20/NOV/2008 05:36:51.971094 PM
    10897523P7013MC0010092     10897523P7     013     001     03     20/NOV/2008     23/MAR/2010 04:00:21.801816 PM
    10897523P7013MR0030082     10897523P7     013     003     03     20/NOV/2008     23/MAR/2010 04:03:01.402111 PM
    Filter records
    10897523P7013MC0010062     10897523P7     013     001     03     20/NOV/2008     20/NOV/2008 05:26:13.205097 PM
    10897523P7013MR0030052     10897523P7     013     003     03     20/NOV/2008     20/NOV/2008 05:26:42.587605 PM
    Rule:
    Row with transaction_type 03's after a group 09 or 10 before the next 07 or 06

    Like this?
    with t
    as
    select '10897523P7013MC0010072' pc_covkey, '10897523P7' policy_number, '013' term_ident, '001' coverage_number, '10' transaction_type,     to_date('17/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('20/NOV/2008 05:36:45.482025 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MR0030062' pc_covkey, '10897523P7' policy_number, '013' term_ident, '003' coverage_number, '10' transaction_type,     to_date('17/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('20/NOV/2008 05:36:45.514349 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MC0010062' pc_covkey, '10897523P7' policy_number, '013' term_ident, '001' coverage_number, '03' transaction_type,     to_date('20/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('20/NOV/2008 05:26:13.205097 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MR0030052' pc_covkey, '10897523P7' policy_number, '013' term_ident, '003' coverage_number, '03' transaction_type,     to_date('20/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('20/NOV/2008 05:26:42.587605 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MC0010082' pc_covkey, '10897523P7' policy_number, '013' term_ident, '001' coverage_number, '07' transaction_type,     to_date('20/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('20/NOV/2008 05:36:51.605820 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MR0030072' pc_covkey, '10897523P7' policy_number, '013' term_ident, '003' coverage_number, '07' transaction_type,     to_date('20/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('20/NOV/2008 05:36:51.971094 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MC0010092' pc_covkey, '10897523P7' policy_number, '013' term_ident, '001' coverage_number, '03' transaction_type,     to_date('20/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('23/MAR/2010 04:00:21.801816 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    union all
    select '10897523P7013MR0030082' pc_covkey, '10897523P7' policy_number, '013' term_ident, '003' coverage_number, '03' transaction_type,     to_date('20/NOV/2008', 'dd/MON/yyyy') cov_chg_eff_date, to_timestamp('23/MAR/2010 04:03:01.402111 PM', 'dd/MON/yyyy hh:mi:ss.ff PM') timestamp_entered from dual
    select *
      from (
              select lag(transaction_type) over(order by cov_chg_eff_date, timestamp_entered) prev,
                     lead(transaction_type) over(order by cov_chg_eff_date, timestamp_entered) post,
                     t.*
                from t
    where transaction_type = '03'
       and prev in ('03', '09', '10')
       and post in ('03', '07', '06')
      

  • Tough question for java beginning expert

    Hi, y'all,
    I couldn't compile "HelloWorld". I downloaded jdk1.3.1_01 and tried to compile "HelloWorld" in MS-DOS. However, the error is: "cannot read HelloWorld.java." I couldn't figure out what's wrong.
    Here's my source code:---------
    class HelloWorld{
    public static void main (String[ ] args) {
    System.out.println("What's wrong with you?");
    Here's my DOS command:--------
    Microsoft Windows 2000 [Version 5.00.2195]
    (C) Copyright 1985-2000 Microsoft Corp.
    C:\>cd java\
    C:\java>dir
    Volume in drive C has no label.
    Volume Serial Number is 07D1-0B0D
    Directory of C:\java
    11/23/2001 01:06p <DIR> .
    11/23/2001 01:06p <DIR> ..
    11/24/2001 01:37a 135 HelloWorld.java.txt
    1 File(s) 135 bytes
    2 Dir(s) 76,506,595,328 bytes free
    C:\java>javac HelloWorld.java
    error: cannot read: HelloWorld.java
    1 error
    C:\java>cd c:\
    C:\>jdk1.3.1_01\bin\javac HelloWorld.java
    error: cannot read: HelloWorld.java
    1 error
    C:\>
    Please Help me. Thanks.
    lee

    Yes, notepad has this "helpful" feature of adding ".txt" to the name of files whose extension is not registered. You'll need to register the "java"-file type if you don't want to get problems like this again.
    On the other hand, notepad is not a very text editor for programming in the first place, so I recommend getting a more adept one. Features that you should be looking for include sytax highlighting and bracket matching - they make it easier to spot stupid typos.

  • Question on Analytical Function

    With below data
    create table Orders
    order_no number,
    item_code varchar2(100)
    insert into orders values (1, 'Item-1');
    insert into orders values (1, 'Item-2');
    insert into orders values (1, 'Item-3');
    insert into orders values (2, 'Item-7');
    insert into orders values (2, 'Item-8');
    insert into orders values (3, 'Item-2');
    insert into orders values (3, 'Item-1');
    insert into orders values (3, 'Item-3');
    insert into orders values (4, 'Item-7');
    insert into orders values (4, 'Item-8');
    commit;
    Is it possible to get below output.
    Order Item Rank
    1 Item-1 1
    1 Item-2 1
    1 Item-3 1
    3 Item-1 1
    3 Item-2 1
    3 Item-3 1
    2 Item-7 2
    2 Item-8 2
    4 Item-7 2
    4 Item-8 2
    thanks,
    Shri

    ORDER is a reserved word so not a suitable column alias (unless you use quoted identifiers):
    SQL> select * from
      2    (select order_no order,item_code item,dense_rank() over (order by item_code) rank
      3       from orders);
    select * from
      (select order_no order,item_code item,dense_rank() over (order by item_code) rank
         from orders)
    ORA-00923: FROM keyword not found where expectedAnd using quoted identifiersl gives:
    SQL> select * from
      2    (select order_no "order",item_code item,dense_rank() over (order by item_code) rank
      3       from orders)
      4  /
         order ITEM                                                                                   RANK
             1 Item-1                                                                                    1
             3 Item-1                                                                                    1
             1 Item-2                                                                                    2
             3 Item-2                                                                                    2
             1 Item-3                                                                                    3
             3 Item-3                                                                                    3
             4 Item-7                                                                                    4
             2 Item-7                                                                                    4
             4 Item-8                                                                                    5
             2 Item-8                                                                                    5
    10 rows selected

  • Discoverer Analytic Function windowing - errors and bad aggregation

    I posted this first on Database General forum, but then I found this was the place to put it:
    Hi, I'm using this kind of windowing function:
    SUM(Receitas Especificas) OVER(PARTITION BY Tipo Periodo,Calculado,"Empresa Descrição (Operador)","Empresa Descrição" ORDER BY Ini Periodo RANGE BETWEEN INTERVAL '12' MONTH PRECEDING AND INTERVAL '12' MONTH PRECEDING )
    If I use the "Receitas Especificas SUM" instead of
    "Receitas Especificas" I get the following error running the report:
    "an error occurred while attempting to run..."
    This is not in accordance to:
    http://www.boku.ac.at/oradoc/ias/10g(9.0.4)/bi.904/b10268.pdf
    but ok, the version without SUM inside works.
    Another problem is the fact that for analytic function with PARTITION BY,
    this does not work (shows the cannot aggregate symbol) if we collapse or use "<All>" in page items.
    But it works if we remove the item from the PARTITION BY and also remove from workbook.
    It's even worse for windowing functions(query above), because the query
    only works if we remove the item from the PARTITION BY but we have to show it on the workbook - and this MAKES NO SENSE... :(
    Please help.

    Unfortunately Discoverer doesn't show (correct) values for analytical functions when selecting "<All>" in a page item. I found out that it does work when you add the analytical function to the db-view instead of to the report as a calculation or as a calculated item on the folder.
    The only problem is you've to name all page-items in the PARTITION window, so, when adding a page-item to the report, you,ve to change the db-view and alter the PARTITION window.
    Michael

Maybe you are looking for

  • Final Cut Pro X to Premiere CS6 workflow destroys FCP X events

    Hello, I just got a call by a customer who tried to convert and FCP X project via XML to Premiere CS6 for a further AfterEffects workflow. He experienced the following problem, which I can rebuild completely. These are the steps: 1 - Export an FCP X

  • SB 5.1 Digital doesn't give 5.1 Testso

    I have a SB 5. Digital connected via coax cable from SB digital out to my dts receiver. The Testsound in the sb 5. mixer should let me hear 6 channels. but i only hear front left and front right. the other channels are mute. the signla input on my re

  • IPod not charging after only 6 months

    After only 6 months, my iPod (color display) seems to have stopped taking charges. When plugged into computer, a very faint image appears saying something like "Battery power very low." We brought to an iPod store. They said the battery is fine, and

  • Entry for condition type missing in table PRCC_COND_CT

    Hi guys, I got this error message in my BDoc. It ask me to "Fill the table PRCC_COND_CT bu using a Customizing download, and then restart the rolled back block in the inbound queue." I am not too sure what is a customizing download. Can you guys help

  • CUOM with Third-party SIP Device

    Hi everyone, I have installed CUOM in environment with CUCM, Cisco IPPhones (SCCP), and IPPhones (Third-party SIP Device), I can monitor CUCM and SCCP IPPhones but the Third-party SIP Device can't be monitored with CUOM, Please someone have a solutio