Turn the query into a GROUP BY

I'm turning the query below, so he produced the first line of each user, each combination of responsibility:

Select a.LOGIN_ID, a.START_TIME, a.END_TIME, c.RESPONSIBILITY_NAME, b.USER_ID, d.USER_NAME in the FND_LOGIN_RESPONSIBILITIES,
fnd_logins b,
FND_RESPONSIBILITY_tl c,
fnd_user d
where
a.LOGIN_ID=b.LOGIN_ID
and a.RESPONSIBILITY_ID=c.RESPONSIBILITY_ID
and b.USER_ID=d.USER_ID
order by d.user_name, c.responsibility_name, a.end_TIME desc nulls last
For a unique combination of the user and the responsibility, it should only return the first value. Currently it is multiple outputs back int the format:
 LOGIN_ID START_TIM END_TIME  RESPONSIBILITY_NAME                                        USER_ID USER_NAME
---------- --------- --------- ------------------------------------------------------- ---------- -------------------------------------------------------
   1487207 23-NOV-11 23-NOV-11 XXX  Payables Supervisor                                1236 ZZZ
   1487207 23-NOV-11 23-NOV-11 XXX  Payables Supervisor                                1236 ZZZ
   1480785 22-NOV-11 22-NOV-11 XXX  Payables Supervisor                                1236 ZZZ
   1478246 22-NOV-11 22-NOV-11 XXX  Payables Supervisor                                1236 ZZZ
   1478246 22-NOV-11 22-NOV-11 XXX  Payables Supervisor                                1236 ZZZ
   3149187 14-DEC-12 14-DEC-12 XXX Imprest Employee Responsibility                           5825 
   3136830 11-DEC-12 11-DEC-12 XXX Imprest Employee Responsibility                           5825 ZZZ
   3102226 03-DEC-12 03-DEC-12 XXX Imprest Employee Responsibility                           5825 ZZZ
   3094387 30-NOV-12 30-NOV-12 XXX Imprest Employee Responsibility                           5825 ZZZ
   3094387 30-NOV-12 30-NOV-12 XXX Imprest Employee Responsibility                           5825 ZZZ
   3093463 29-NOV-12 29-NOV-12 XXX Imprest Employee Responsibility                           5825 ZZZ
   3090327 29-NOV-12 29-NOV-12 XXX Imprest Employee Responsibility                           5825 ZZZ
This should only output as below:
 LOGIN_ID START_TIM END_TIME  RESPONSIBILITY_NAME                              USER_ID USER_NAME
---------- --------- --------- ------------------------------------------------------- ---------- -------------------------------------------------------
 1487207 23-NOV-11 23-NOV-11 XXX  Payables Supervisor                                1236       ZZZ
 3149187 14-DEC-12 14-DEC-12 XXX Imprest Employee Responsibility                   5825      ZZZ
My version of the database is 11.2.0.2.0

James

A way

select *
from
(
select      a.LOGIN_ID,a.START_TIME,a.END_TIME,
     c.RESPONSIBILITY_NAME,b.USER_ID,d.USER_NAME,
     row_number() over(partition by d.user_name, c.responsibility_name
                     order by a.end_TIME desc nulls last ) rn
from      FND_LOGIN_RESPONSIBILITIES a,
     fnd_logins b,
     FND_RESPONSIBILITY_tl c,
     fnd_user d
where a.LOGIN_ID=b.LOGIN_ID
and a.RESPONSIBILITY_ID=c.RESPONSIBILITY_ID
and b.USER_ID=d.USER_ID
)
where rn = 1
order by user_name, responsibility_name

Tags: Database

Similar Questions

  • Password - when I turn the computer into a big red box with the words "Enter your password" appears

    When I turn on the computer a big red box with the words "enter your password" arrives, we cannot go into the user explains, I forgot the password. We can't still press Delete to enter in the configuration because it is in the Enter password screen and can't live without her.

    If anyone can help in this matter.

    Kind regards

    Dennis

    Hello

    Contact the manufacturer of the computer to this topic as it seems to be a BIOS password forgotten

    I'm sorry, but the strategy of microsoft in these forums is that without assistance will be given about lost or forgotten passwords

    read the policy at the link below

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-security/keeping-passwords-secure-Microsoft-policy-on/a5839e41-b80e-48c9-9d46-414bc8a8d9d4

  • Help turn the query that returns single return system

    Hello, I have two tables, readings, and values. Values have a foreign key to the readings.
    create table readings 
    (
    id number primary key,
    point number,
    datereading date
    );
    
    create table reading_values
    (
    id number primary key,
    counter_nr number,
    point number,
    reading_id number,
    datereading date,
    CONSTRAINT fk_reading
    FOREIGN KEY (reading_id)
    REFERENCES readings (id)
    );
    The point and datereadings columns have the same value of related rows.
    insert into readings values (1, 1234, to_date('20100622 12:12', 'yyyymmdd HH24:MI'));
    insert into reading_values values (1, 0, 1234, 1, to_date('20100622 12:12', 'yyyymmdd HH24:MI')); --row1
    insert into reading_values values (2, 1, 1234, 1, to_date('20100622 12:12', 'yyyymmdd HH24:MI')); --row2
    
    insert into readings values (2, 1234, to_date('20100623 12:12', 'yyyymmdd HH24:MI'));
    insert into reading_values values (3, 0, 1234, 2, to_date('20100623 12:12', 'yyyymmdd HH24:MI')); --row3
    insert into reading_values values (4, 1, 1234, 2, to_date('20100623 12:12', 'yyyymmdd HH24:MI')); --row4
    
    insert into readings values (3, 1111, to_date('20100621 12:12', 'yyyymmdd HH24:MI'));
    insert into reading_values values (5, 0, 1111, 3, to_date('20100623 12:12', 'yyyymmdd HH24:MI')); --row5
    Now I have the procedure which the entry: p_point and p_date.
    select * from reading_values rv, 
    (select * from (select id, datereading
    from readings where datereading < p_date and point = p_point
     order by datereading desc) where rownum <= 1) t where rv.reading_id = t.id
    so I want the previous reading_values (in time based on p_date) for a certain point p_date. I hope this makes sense?
    Example:
    select * from reading_values rv, 
    (select * from (select id, datereading
    from readings where datereading < to_date('20100624 12:12', 'yyyymmdd HH24:MI') and point = 1234
     order by datereading desc) where rownum <= 1) t where rv.reading_id = t.id
    
    returns row 3 and 4
    Now, what I want to do, is replace p_point and p_date with two collections. For example: p_points = [1234, 1111] p_dates = [20100622 15:12, 20100624 12:12]
    Here, I want to have the previous reading_values by point = 1234 and datereading < 20100622 order 15:12 by datereading (where rownum < = 1).

    and also reading_values by point = 1111 and datereading < 20100624 order 12:12 by datereading (where rownum < = 1).

    This should return line1, line2 and row5...

    So far I came up with this. But I can't be sure that it is correct. And the performance seems to be horrible (cost 88, 13 recursive calls, 155 becomes uniform) for a query with 2 entry points and 2 dates compared to the original to just a single point query and the date of entry (cost 13, 1 recursive call and gets 14 coherent).
    Select rv.* from (SELECT r.id
          FROM    Readings r, 
          (select rownum rn1, t1.id from table1 t1 order by id) t1, -- input parameter1 (point collection)
          (select rownum rn2, t2.date_now from table1 t2 order by id) t2  -- input parameter 2 (date collection)
          WHERE  r.point = t1.id
              AND     r.datereading = (SELECT  max(r2.datereading)
              FROM   Readings r2
                WHERE   r2.point = t1.id
                AND     r2.datereading < t2.date_now AND rn1 = rn2)
        ) r, Reading_Values rv where r.id= rv.reading_id;
    code for creating table 1 that I used instead of collections of entry:
    create table table1
    (
     id number not null primary key,
     date_now date not null
    );
    insert into table1 values (1234, to_date('20100622 15:12', 'yyyymmdd HH24:MI'));
    insert into table1 values (1111, to_date('20100624 12:12', 'yyyymmdd HH24:MI'));
    Hope someone can help me on my way :) Please ask if something is unclear or strange! Thank you!

    Published by: KarlTrumstedt on 23-jun-2010 06:20

    Try this

    SELECT RV.ID, RV.COUNTER_NR, RV.POINT, RV.READING_ID, RV.DATEREADING
    FROM (
        SELECT (    SELECT LAST_VALUE(RE.ID) OVER
                         (PARTITION BY RE.POINT ORDER BY RE.DATEREADING)
                    FROM READINGS RE
                    WHERE RE.DATEREADING < T1.DATE_NOW AND RE.POINT = T1.ID
                ) ID,
                T1.ID POINT,
                T1.DATE_NOW
        FROM TABLE1 T1
    ) X
    JOIN READING_VALUES RV
    ON (X.ID = RV.READING_ID AND X.POINT = RV.POINT)
    ;
    
  • Spectrum X 360: New spectrum X 360 does not turn the screen into tablet mode

    My spectrum is only two weeks old and works wonderfully as a standard notebook computer.

    However, I cannot get screen to turn when I select tablet mode or Flip on the stand of entertainment.

    All the research online, I can find are people who used Win 8.1 and is updated to Win 10.

    Mine came with Win 10 pre-installed.

    None of the screens settings they advise to go to exist.

    I also checked the registry and its game properly.

    Windows 10 made the anniversary update a few days in me starts to use it so I don't know WHETHER or not the rotation number was there from the beginning.

    I solved my problem re. the screen does not turn in tablet mode.

    Yesterday, I installed HP Support Assistant in the hope, he suggests a solution.

    It didn't at the time, but it made me on this forum where I see that many others had similar problems.

    Today, when I turned on my laptop I noticed that support Assistant has a list of available updates.

    the first who has updated automatically has been updated for HP Notebook System Bios (Intel processors) which, after installation and reboot I had not really noticed any difference.

    Among the list of updates has been 'Intel Integrated Sensor Solution Drivers'

    Because I couldn't find any menition of sensors in my device manager, I installed it.

    Now I have the "Lock Rotation of this view" option may be greyed out there but at least now it.

    Still no spin so I started to double check every thing once again and found that I had a new entry in the registry... Sensor

    present.

    However Enable is set to 0 instead of 1

    I changed the 0 to 1 and here I rotation.

    However the only question now is the Rotation options buttons are greyed out, but I still can auto rotate when I flip to the tent, entatainment or tablet mode.

    At least, that my X 360 so that its name and what I bought it for.

    Fact my research I love the lack of rotation is not a specific HP problem but a problem of Windows 10.

    If other problems persist, try to reduce your search settings to fail to win 10 to rotaate, you will see a lot more information out there.

    Thanks to everyone who tried to help me. I hope that my message will help someone else.

  • turns the children into columns

    Hi, I want to change children in columns

    Examples of data

    FM3MGR
    1
    21
    31
    42
    52

    Expected results

    MGRCHILD1CHILD2
    123
    245

    Please help me

    If you are sure, then maybe:

    with

    BaseData as)

    Select 1 emp, mgr of the double null

    Union of all the

    Select 2 1 (IEM), Bishop of the double

    Union of all the

    Select 3 1 (IEM), Bishop of the double

    Union of all the

    Select option 4 2 (IEM), Bishop of the double

    Union of all the

    Select 5 2 (IEM), Bishop of the double

    )

    ,

    basedata_ordered like)

    Select t.*

    row_number() over (partition by order of Bishop of emp) rn

    of basedata t

    )

    Select mgr

    , max (case when rn = 1 then emp end otherwise null) Child1

    , max (case when rn = 2 then emp end otherwise null) Child2

    of basedata_ordered

    where Bishop is not null

    Group by mgr

    ;

    BISHOP CHILD1 CHILD2

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

    1          2          3

    2          4          5

  • Copy and paste the query into the Action of the CS3

    Hello

    Assistance to an inexperienced user please.

    My plan is to open a main image, as well as 4 other images and then save an action to be used with 5 images open. I have a "Stop" inserted first remember to open the 5 pictures before continuing.

    It will initially copy each of 4 additional images and paste as a new layer content in the main image, and then close the additional image. This step will end with 1 image open with 4 new layers, ready for the next step.

    In essence, I have work, but it is the source of the problems.

    Sometimes the said script Action "Select document + 4", another time "select Document - 4" and other times "Select previous document".

    I'm kinda assuming that the problem comes from the 'reference' documentation, but unlike layers, I assume that I can not give specific names for use trhem in action.

    Does it matter in which order I opened 5 images? Given that the action is written using the 'main' image, he is always on the top and pick when I start.

    It also seems to count in what order I do things. Am I right in assuming that I should wait until all 4 layers are glued together before closing all images, as this seems to be a problem because once I close 1 picture there are only 4 left, so the "SEO" is corrupt.

    It should be simple, but when I try with different images, it does not work.

    Any commnets welcome.

    Thank you

    Colin

    Go to file-> information file. If tab Description, status of copyright rights of author's value dropdown, then you get the © symbol.

  • How to turn the "words" in a link

    I would like to know how to turn the words into link instead of posting the link.

    Example: I copy and paste this one answers...

    Microsoft PowerPoint 2007 Viewer .

    For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

    Try the PowerPoint Viewer .
    one more time...  PowerPoint Viewer

    AH, I got it.

    Here are the steps...
    Go to the site, copy the url > open back a response or a quote > type the message > on the words, I want to be connect, cursor over the first word > click and hold > slide down to the last word, I want to be a link, hold for release > click on insert/edit the link, a box will appear > paste the url inside this little box > click Insert
    That's all.

    Thanks Andre for the lead.

    For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • Need help in the optimization of the query with the Group and joins by clause

    I'm having the problem by running the following query... It takes a lot of time. To simplify, I added the two tables FILE_STATUS = stores the file load details and COMM table Board table job showing records treated successfully and which was communicated to the other system real. Records with status = T is trasnmitted to another system and traansactions with P is waiting.
    CREATE TABLE FILE_STATUS
    (FILE_ID VARCHAR2(14),
    FILE_NAME VARCHAR2(20),
    CARR_CD VARCHAR2(5),
    TOT_REC NUMBER,
    TOT_SUCC NUMBER);
    
    CREATE TABLE COMM
    (SRC_FILE_ID VARCHAR2(14),
    REC_ID NUMBER,
    STATUS CHAR(1));
    
    INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
    INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
    
    INSERT INTO COMM VALUES ('12345678', 1, 'T');
    INSERT INTO COMM VALUES ('12345678', 3, 'T');
    INSERT INTO COMM VALUES ('12345678', 4, 'P');
    INSERT INTO COMM VALUES ('12345678', 5, 'P');
    COMMIT;
    Here's the query I wrote to give me the details of the file that has been loaded into the system. He reads the table of State and the commission files to display the name of the file, total records loaded, total at the table of the commission and the number of records which has finally been passed successfully loaded (Status = T) with other systems.
    SELECT 
        FS.CARR_CD 
        ,FS.FILE_NAME 
        ,FS.FILE_ID
        ,FS.TOT_REC
        ,FS.TOT_SUCC
        ,NVL(C.TOT_TRANS, 0) TOT_TRANS
    FROM FILE_STATUS FS
    LEFT JOIN
    (
        SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
        FROM COMM
        WHERE STATUS = 'T'
        GROUP BY SRC_FILE_ID
    ) C ON C.SRC_FILE_ID = FS.FILE_ID
    WHERE FILE_ID = '12345678';
    In production, this request has several joins and takes a long time to deal with... the main culprit for me is the join on the COMM table to count the number of number of transactions sent. Please can you give me tips to optimize this query to get results faster? What I need to delete the Group and use the partition or something else. Help, please!

    Don't know if it will be faster based on the information provided, but analytical functions offer an alternative approach;

    select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
      from (select fs.carr_cd,
                   fs.file_name,
                   fs.file_id,
                   fs.tot_rec,
                   fs.tot_succ,
                   count(case
                            when c.status = 'T' then
                             1
                            else
                             null
                          end) over(partition by c.src_file_id) tot_trans,
                   row_number() over(partition by c.src_file_id order by null) rn
              from file_status fs
              left join comm c
                on c.src_file_id = fs.file_id
             where file_id = '12345678')
     where rn = 1;
    
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
    ------- -------------------- -------------- ---------- ---------- ----------
    LIBM    CM_LIBM.TXT          12345678                5          4          2
    
  • I need to stop a download of the query, I thought a stand-alone application but turns require a higher level (FCPX) as a 'parent' and I do not who have, or want to buy.

    I need to stop a download of the query, that I thought a stand-alone application but turns require a higher level (FCPX) as a 'parent' and I do not have that, or I want to buy it.

    Motion IS a stand-alone application. It is mainly designed to make effects for Final Cut Pro X, but it is not necessary to have with FCPX nor is it necessary to have FCPX to create projects for other purposes. When you open the query, simply select project of work outside the FCPX motion. You can save regular projects of Motion anywhere on your system.

  • Using the query to get the group by rollup subtotal

    Hello

    Expected output is, for 'chris' each record must have subtotal row because it has different 'no' of the column values.

    For 'John' the subtotal came as planned because she didn't even.

    Could you please correct the query for "chris" below!

     select   
    case when nm is null then 'Total'  
         when no is null then 'Subtotal'  
         else nm  
    end nm,no,emplmt,profund,status,dt,sal,days,intrst,intrs1,intrs2  
    from   
    (  
        with t as     
            (select 'chris' nm , 10 no ,'FT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('01/22/2014','mm/dd/yyyy') dt , 2456 sal, 10 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual    
            union all    
            select 'chris' nm , 20 no ,'FT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('01/03/2014','mm/dd/yyyy') dt , 1000 sal, 30 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual    
            union all    
            select 'chris' nm , 30 no ,'FT' Emplmt, 'PF' ProFund , 'NonReg' Status ,to_Date ('01/01/2014','mm/dd/yyyy') dt , 20 sal, -5 days , 1 intrst ,1 intrs1 ,1 intrs2 from dual    
           union all
           select 'john' nm , 11 no ,'PT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('05/02/2014','mm/dd/yyyy') dt , 1153 sal, 10 days , 50 intrst ,55 intrs1 ,60 intrs2 from dual    
            union all    
            select 'john' nm , 11 no ,'PT' Emplmt, 'PF' ProFund , 'Reg' Status ,to_Date ('05/16/2014','mm/dd/yyyy') dt , 1000 sal, 8 days , 40 intrst ,45 intrs1 ,50 intrs2 from dual    
    
    
           )    
        select nm,no,emplmt,profund,status,dt,sum(sal)sal,sum(days)days,sum(intrst)intrst,sum(intrs1)intrs1,sum(intrs2)intrs2  
        from t  
        GROUP BY ROLLUP (nm,no,emplmt,profund,status,dt)  
        order by nm,no,emplmt,profund,status,dt  
    )  
    where (no is not null and emplmt is not null and profund is not null and status is not null and dt is not null)  
    or (no is null and emplmt is null and profund is null and status is null and dt is null)  
    

    allows us to use grouping sets to produce just the totals you want.

    with t as

    (select "chris" nm1, 10 no1, "Pi" Emplmt, "PF" ProFund "Reg" Status, to_Date (January 22, 2014 "," mm/dd/yyyy") dt, 2456 sal, 10 days, 50 intrst, intrs1 55 intrs2 60 double)

    Union of all the

    Select No, the "chris" nm, 20 'ft' Emplmt, "PF" ProFund "Reg" Status, to_Date (3 January 2014 "," mm/dd/yyyy") dt, intrst 50, intrs1 55, 1000 sal, 30 days, 60 intrs2 of the double

    Union of all the

    Select "chris" nm, 30 no, "Pi" Emplmt, ProFund "PF", "NonReg" State, to_Date (January 1, 2014 "," mm/dd/yyyy") dt, 20 sal,-5 days, 1 intrst, 1 intrs1, 1 intrs2 of the double

    Union of all the

    Select "Jean" nm, 11 no, "PT" Emplmt, "PF" ProFund "Reg" Status, to_Date (May 2, 2014 "," mm/dd/yyyy") dt, 1153 sal, 10 days, 50 intrst, intrs1 55 intrs2 60 double

    Union of all the

    Select "Jean" nm, 11 no, "PT" Emplmt, "PF" ProFund "Reg" Status, to_Date (16 may 2014 "," mm/dd/yyyy") dt, 1000 sal, 8 days, intrst 40, 45 intrs1, 50 intrs2 of the double

    )

    SELECT

    CASE

    WHEN grouping (nm1) = 1

    THEN "Total".

    WHEN grouping (emplmt) = 1

    THEN "Subtotal".

    Of ANOTHER nm1

    END nm,

    CASE

    WHEN grouping (emplmt) = 1

    THEN NULL

    Of ANOTHER no1

    END no emplmt, profund, status, dt, sal SUM (sal), SUM (days) days, SUM (intrst) intrst, SUM (intrs1) intrs1, intrs2 SUM (intrs2)

    T

    GROUP BY Grouping SETS ((), (nm1, no1), (nm1, no1, emplmt, profund, status, dt))

    ORDER BY nm1, no1, emplmt, profund, status, dt

    NM               NO EM PR STATUS DT              SAL       DAYS     INTRST     INTRS1     INTRS2 chris            10 FT PF Reg    22.01.14       2456         10         50         55         60 Subtotal                                        2456         10         50         55         60chris            20 FT PF Reg    03.01.14       1000         30         50         55         60 Subtotal                                        1000         30         50         55         60chris            30 FT PF NonReg 01.01.14         20         -5          1          1          1 Subtotal                                          20         -5          1          1          1john             11 PT PF Reg    02.05.14       1153         10         50         55         60 john             11 PT PF Reg    16.05.14       1000          8         40         45         50Subtotal                                        2153         18         90        100        110 Total                                           5629         53        191        211        231 
    
  • The MPEG-4 movie that I imported into the timeline of video group Photoshop plays in slow motion. How to play at normal speed?

    I am highly skilled in Photoshop for still photography, but go with the video. The problem I have encountered is the following:

    The MPEG-4 movie that I imported into the timeline of video group Photoshop plays in slow motion. How to play at normal speed?

    This must be a common problem. I would appreciate some words of wisdom.

    Thank you

    Victor

    The only way to do it with Photoshop, is to right-click on the clip and change the speed.  So if the clip was recorded at 60 fps and you use it on a timeline of 30 fps, set the speed to 200%

    Applications like Premiere Pro and After Effects (and possibly first Elements) allow you to change the frequency of images in sequence by sequence.   Photoshop is a tool very frustrating to use for video editing.  Premiere Elements existed comes with Photoshop Elements for a very reasonable price.  I have no experience with Premiere Elements, but I strongly suspect that this will be an order of magnitude better than Photoshop for video editing.

    Adobe Premiere Pro vs elements - comparison of video editors

  • I use photoshop 5.1. I'm painting a picture. previously in the tool hue/saturation from the drop of the image then adjustments, I was able to turn an image into sepia or cyanotype so that change the hue, saturation &amp; lightness, but TH

    I use photoshop 5.1. I'm painting a picture. previously in the tool hue/saturation from the drop of the image then adjustments, I was able to turn an image into sepia or cyanotype as well as change the hue, saturation & lightness, but the minute his does not give me this option. can anyone help?

    To reset the preferences:

    If Photoshop is already open on your screen, close (Quit). Then press and hold Shift + Ctrl + Alt (Win) / command + shift + Option (Mac) on your keyboard and start Photoshop.

    A dialog box appears asking if you want to delete the preferences file existing ("settings"). Click Yes in the dialog box. The existing preferences file will be discarded and a new one will be created.

  • Ask for help with the query group by

    Hello
    I have the following table with values structure
    CREATE TABLE DUMMY
      (
        SR_NUMBER          VARCHAR2(100 CHAR),
        ASSIGNMENT_GROUP   VARCHAR2(100 CHAR),
        REASSIGNMENT_COUNT VARCHAR2(100 CHAR),
        CREATED DATE,
        CLOSED DATE,
        TARGET_DATE DATE
     )
     
     insert into dummy values('AAA','A','1','02-OCT-11','25-OCT-11','09-OCT-11');
     insert into dummy values('ABC','A','1','03-SEP-12','26-SEP-11','10-SEP-11');
     insert into dummy values('AVB','A','1','02-NOV-13','25-NOV-13','09-NOV-13');
     insert into dummy values('AFT','B','1','02-OCT-11','25-OCT-11','09-OCT-11');
     insert into dummy values('ACS','B','1','02-JAN-12','25-JAN-12','09-JAN-12');
     insert into dummy values('AVC','B','1','02-OCT-13','25-OCT-13','09-OCT-13');
     insert into dummy values('AAD','B','1','02-MAR-14','25-MAR-14','09-MAR-14');
     insert into dummy values('AAA','C','1','02-OCT-11','25-OCT-11','09-OCT-11');
    insert into dummy values('AAA','D','1','02-JUN-11','25-JUN-11','09-JUN-11');
    insert into dummy values('AAA','E','1','02-APR-12','25-APR-12','09-APR-12');
    insert into dummy values('AAA','A','1','02-FEB-13','25-FEB-13','09-FEB-13');
    
    ?
    I have the following requirement, the output should be:

    Number of ticket (sr_number)
    % of tickets inside the DL
    Number of tickets inside the DL
    Average cycle time (cycle time = closing date - date of creation)
    Total cycle time (cycle time = closing date - date of creation)
    Number of reallocations (sum)


    DL - (deadline) formula is, closed date < = target_date

    This should be displayed, grouped by year, then month, then the assignment group. The values must be in descending order (dates) is not sure that group in operation here.
    I am able to write the code base of the foregoing, but group from the year, month, and group assignment is pretty confusing to me.


    Can someone give me a voucher code...

    This may not give you exactly what you want, but if all goes well, it will give you something to work with:

    WITH tickets AS (
      SELECT TO_CHAR(created, 'YYYY') created_year,
             TO_CHAR(created, 'MM') created_month,
             assignment_group,
             COUNT(sr_number) ticket_count,
             AVG(closed - created) avg_cycle_time,
             SUM(closed - created) tot_cycle_time,
             COUNT(reassignment_count) reassign_count
       FROM dummy
       GROUP BY TO_CHAR(created, 'YYYY'),
                TO_CHAR(created, 'MM'),
                assignment_group
    ),
    dl_tickets AS (
      SELECT TO_CHAR(created, 'YYYY') created_year,
             TO_CHAR(created, 'MM') created_month,
             assignment_group,
             COUNT(sr_number) ticket_in_dl_count
        FROM dummy
        WHERE closed <= target_date
        GROUP BY TO_CHAR(created, 'YYYY'),
              TO_CHAR(created, 'MM'),
              assignment_group
    )
    SELECT t.created_year,
           t.created_month,
           t.assignment_group,
           t.ticket_count,
           NVL(dl.ticket_in_dl_count, 0) ticket_in_dl_count,
           NVL(dl.ticket_in_dl_count/t.ticket_count, 0) * 100 pct_ticket_in_dl_count,
           t.avg_cycle_time,
           t.tot_cycle_time,
           t.reassign_count
      FROM tickets t,
           dl_tickets dl
      WHERE t.created_year = dl.created_year (+)
      AND t.created_month = dl.created_month (+)
      ORDER BY created_year DESC, created_month DESC
    

    Published by: user1983440 on May 27, 2013 15:47 - added reassign_count

    Published by: user1983440 on May 27, 2013 15:54 - added ORDER BY

  • Rewrite the query with joins, and group by

    Hello

    It's an interview question.

    Table names: bookshelf_checkout
    virtual library

    And the join condition between these two tables is title

    We need to rewrite under request without using the join condition and group by clause?

    SELECT b.title,max(bc.returned_date - bc.checkout_date) "Most Days Out"
               FROM bookshelf_checkout bc,bookshelf b
               WHERE bc.title(+)=b.title
               GROUP BY b.title;
    When I was in College, I read most of SELECT statements can be replaced by operations base SQL (DEFINE the OPERATORS). Now, I am rewriting the query with SET operators, but not able to get the exact result.

    Kindly help me on this.

    Thank you
    Suri

    Something like that?

      1  WITH books AS (
      2  SELECT 'title 1' title FROM dual UNION ALL
      3  SELECT 'title 2' FROM dual UNION ALL
      4  SELECT 'title 3' FROM dual ),
      5  bookshelf AS (
      6  SELECT 'title 1' title, DATE '2012-05-01' checkout_date, DATE '2012-05-15' returned_date FROM dual UNION ALL
      7  SELECT 'title 1' title, DATE '2012-05-16' checkout_date, DATE '2012-05-20' returned_date FROM dual UNION ALL
      8  SELECT 'title 2' title, DATE '2012-04-01' checkout_date, DATE '2012-05-15' returned_date FROM dual )
      9  SELECT bs.title, MAX(bs.returned_date - bs.checkout_date) OVER (PARTITION BY title) FROM bookshelf bs
     10  UNION
     11  (SELECT b.title, NULL FROM books b
     12  MINUS
     13* SELECT bs.title, NULL FROM bookshelf bs)
    SQL> /
    
    TITLE   MAX(BS.RETURNED_DATE-BS.CHECKOUT_DATE)OVER(PARTITIONBYTITLE)
    ------- ------------------------------------------------------------
    title 1                                                           14
    title 2                                                           44
    title 3
    

    Lukasz

  • The point list - record group Query - bad alignment order

    Dear all,

    When I try to concatenate two columns using the query of the record group and display in the list item, the alignment is not in good condition.

    For example; Here are the columns and data used in the process:

    SHORT_DESC CODE_VALUE DESCRIPTION
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    ROLL1 customer - No accidental Production, by booking with another carrier, bad projection.
    Roll2 client project - accidental l/c, B/L, customs, samples, AMS, LAR.
    ABC - lack of vacuum ROLL3 lack of empty units.
    ABC CDE ROLL4 - Roll on decision of the AGR RRR.
    ROLL5 ABC XXX - Accidental IMO or denied OOG, operational problems, Cut & Run.
    ROLL6 ABC YYY - booking fictitious material buffer, dummy booking.

    This is the query of the record group used in forms:
    ----------------------------------------------------------------
    PROCEDURE p_when_new_form_instance
    IS
    GROUP_ID recordgroup;
    list_id question: = FIND_ITEM ('BLK_CONTROL.) LI_ROLL_REASON');
    rg_name VARCHAR2 (20): = "LI_ROLL_REASONS";
    status NUMBER;
    l_query VARCHAR2 (4000);
    BEGIN
    l_query: =.
    ' SELECT rpad (short_desc, 50, "") | "| ''|| description of the description, code_value code_value OF codes WHERE code_value IN ("ROLL1", "roll2", "ROLL3", "ROLL4", "ROLL5", "ROLL6")';
    GROUP_ID: = CREATE_GROUP_FROM_QUERY (rg_name, l_query);
    status: = POPULATE_GROUP (GROUP_ID);
    POPULATE_LIST (list_id, GROUP_ID);
    EXCEPTION
    WHILE OTHERS
    THEN
    pl_common.when_others;
    END;
    -----------------------------------

    In addition, I have my property list item as the default "" MS SANS SERIF"fonts and when I run in Forms Builder get the alignment as below.

    Result:
    ====
    DESCRIPTION CODE_VALUE
    Customer - Non-accidental. Production, by booking with another carrier, bad projection.     ROLL1
    Customer - Accidental | L/c, B/L project, customs, samples, AMS, LAR.     ROLL2
    ABC - lack of vacuum | Lack of empty units.     ROLL3
    ABC ORDER - to the reversal. Decision of the AGR RRR.     ROLL4
    ABC XXX - Accidental | IMO / denied OOG, operational problems, Cut & Run.     ROLL5
    ABC YYY - booking fictitious | Reservation of equipment, fake buffer.      ROLL6

    More high of the order is not the desired result because all the | (vertical bar) should display in the correct order as below.
    Expected result:
    ==========
    DESCRIPTION CODE_VALUE
    Customer - Non-accidental. Production, by booking with another carrier, bad projection.     ROLL1
    Customer - Accidental | L/c, B/L project, customs, samples, AMS, LAR.     ROLL2
    ABC - lack of vacuum | Lack of empty units.     ROLL3
    ABC ORDER - to the reversal. Decision of the AGR RRR.     ROLL4
    ABC XXX - Accidental | IMO / denied OOG, operational problems, Cut & Run.     ROLL5
    ABC YYY - booking fictitious | Reservation of equipment, fake buffer.      ROLL6


    I tried and RPAD LPAD the alignment problem is still there; I know that the issue is due to the fixed length of the police.
    But is there a solution to replace it it will be a great help.



    So please help!


    Thank you...

    Kind regards
    Sunil.G

    If you can not use non proportional fonts, then forget about having any special alignment, because with proportional fonts, room occupied by each letter is different.

    François

Maybe you are looking for

  • Why Snap to beat does not yet?

    Apple thinks different (in what?) Say, buy imac is the reason for making video with nod to beat Buy the new imac for can have a better performance Open imovie in imac for can use the snap to beat Nod to beat does not work, what should we do? Apple th

  • DVD for Satellite Pro 4600?

    I checked the forum and tech support for my satellite pro 4600. I remember in the past, it was possible to upgrade the standard cdr with another (CD - RW dvd or DVD - RW), dvd - rom am I looking to upgrade?Thank you!Additional information:Toshiba sat

  • Unable to see the voicemail on my iPhone4s while China

    Hello I bought a number of US wanting to my American friends leave me voice messages, then I travel to China. While in the United States, I can see the voicemail and listen to voice messages on the Skype app for iPhone. However, when I was in China,

  • How can I repair the LCD on my Satellite A40?

    The LCD on my Toshiba Satellite A40 monitor has a problem of 'mechanical problem '. It does not yet support as it should. My question is: is it possible to find an instruction for replacing the LCD screen. But I used hours with no result, so I hope y

  • Error 1097 while controlling a Velmex

    I use a configuration of Velmex two axes to quickly move a probe quickly into and out of a flame. The Velmex is supposed to move the probe in the flame, let it recueillir collect data, move it out of the flame, and then repeat the process at a slight