Mark on Group on the priority of the task for each employee

Hi all

We have following the structure of the employees table, the taskallocation & tasks.
CREATE TABLE EMP
   (     "EMP_ID" NUMBER(10,0) NOT NULL ENABLE, 
          "FNAME"     NVARCHAR2(50) NOT NULL ENABLE, 
          "LNAME"     NVARCHAR2(50) NOT NULL ENABLE 
   );    
   
   
CREATE TABLE TASKS
   (     "TASK_ID" NUMBER(10,0) NOT NULL ENABLE, 
          "TASK_PRIORITY" NVARCHAR2(10) NOT NULL ENABLE          
   );   
   
CREATE TABLE TASKSALLOCATION
   (     "TASKALLOCATION_ID" NUMBER(10,0) NOT NULL ENABLE, 
          "EMP_ID" NUMBER(10,0) NOT NULL ENABLE, 
          "TASK_ID" NUMBER(10,0) NOT NULL ENABLE
   );   
   
The same data will be as follows
Insert into EMP (EMP_ID,FNAME,LNAME) values (1,'XYZ','DFD');
Insert into EMP (EMP_ID,FNAME,LNAME) values (2,'DFDS','FD');
Insert into EMP (EMP_ID,FNAME,LNAME) values (3,'FDSF','GFH');
Insert into EMP (EMP_ID,FNAME,LNAME) values (6,'GFHGF','GFHS');
Insert into EMP (EMP_ID,FNAME,LNAME) values (4,'GFD','FDG');
Insert into EMP (EMP_ID,FNAME,LNAME) values (5,'DSFDS','FDSAF');
Insert into EMP (EMP_ID,FNAME,LNAME) values (7,'GHGY','EWE');
Insert into EMP (EMP_ID,FNAME,LNAME) values (8,'FGRFSAD','SADF');

Insert into TASKS (TASK_ID,TASK_PRIORITY) values (1,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (2,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (3,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (4,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (5,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (6,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (7,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (8,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (9,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (10,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (11,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (12,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (13,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (14,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (15,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (16,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (17,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (18,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (19,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (20,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (21,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (22,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (23,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (24,'LOW');

Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (1,1,1);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (2,2,1);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (3,3,2);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (4,3,3);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (5,4,4);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (6,4,5);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (7,4,6);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (8,4,7);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (9,5,6);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (10,6,8);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (11,7,9);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (12,8,8);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (13,8,10);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (14,8,11);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (15,8,12);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (16,6,13);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (17,5,14);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (18,3,12);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (19,3,13);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (20,2,15);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (21,1,16);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (22,2,17);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (23,1,18);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (24,4,19);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (25,6,20);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (26,5,21);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (27,1,22);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (28,3,23);
 
COMMIT;
And we are looking for a number of tasks based on grouping on its priority by employee. Something like that,

ResultSet
with 
    t as 
     (                                        
          select     'XYZ DFD' as EMP_NAME,     3 as HIGH ,     0 as MEDIUM,     1 as LOW FROM dual union all
          select     'DFDS FD'     ,     1     ,     1     ,     1     FROM dual union all
          select     'FDSF GFH'     ,     1     ,     2     ,     2     FROM dual union all
          select     'GFHGF GFHS'     ,     3     ,     1     ,     1     FROM dual union all
          select     'GFD FDG'     ,     0     ,     1     ,     2     FROM dual union all
          select     'DSFDS FDSAF'     ,     1     ,     2     ,     0     FROM dual union all
          select     'GHGY EWE'     ,     0     ,     0     ,     1     FROM dual union all
          select     'FGRFSAD SADF'     ,     1     ,     2     ,     1     FROM dual)
Note: We use the Oracle 11.2.0.2.0 version

Hello

select emp.fname || ' ' || emp.lname EMP_NAME
     , sum(case when tasks.TASK_PRIORITY = 'HIGH' then 1 else 0 end) HIGH
     , sum(case when tasks.TASK_PRIORITY = 'MEDIUM' then 1 else 0 end) MEDIUM
     , sum(case when tasks.TASK_PRIORITY = 'LOW' then 1 else 0 end) LOW
  from emp
  join TASKSALLOCATION
    on emp.EMP_ID = TASKSALLOCATION.EMP_ID
  join TASKS
    on TASKSALLOCATION.TASK_ID = tasks.TASK_ID
 group by emp.fname || ' ' || emp.lname

EMP_NAME                   HIGH     MEDIUM        LOW
-------------------- ---------- ---------- ----------
FGRFSAD SADF                  1          2          1
XYZ DFD                       3          0          1
GHGY EWE                      0          0          1
GFHGF GFHS                    1          2          0
GFD FDG                       3          1          1
DFDS FD                       1          1          1
FDSF GFH                      1          2          2
DSFDS FDSAF                   0          1          2

Concerning

Martin Preiss

Tags: Database

Similar Questions

  • I do my job to the computer on a MAC computer. I want to create a document using Pages and then convert the document to PDF and send a group email. I want to send the PDF using the pdf for each receiver icon must click the icon to open t

    I do my job to the computer on a MAC book PRO. I want to create a document using Pages and then convert the document to PDF and send a group email. I want to send the PDF using the pdf for each receiver icon must click the icon to open the document. My problem is the document does not show the icon, but rather the document is already open. I spoke with 2 Apple. 'Experts' care and can help me. Can someone tell me what to do?

    It's a question of how the recipients e-mail programs deal with attachments. Many e-mail programs will open all the files they can handle, including files jpg and PDF, by default, and if the recipient has not changed that there is nothing you can do about it. The only solution is to the compress first, then it will be delivered as an attachment, allowing the recipient to decompress and open it.

  • I don't see pictures to the owner/documents without opening each file individually. I just see the same image of a mountain and the Lake for each file.

    I don't see pictures (jpeg images) to the owner/documents without opening each file individually.  I just see the same image of a mountain and the Lake for each file.  When I look in windows XP, the JPEGs under 'my computer' and select 'film' or the 'miniature' I can see the image.  Why can I not see the image using Vista?

    I don't see pictures (jpeg images) to the owner/documents without opening each file individually.  I just see the same image of a mountain and the Lake for each file.  When I look in windows XP, the JPEGs under 'my computer' and select 'film' or the 'miniature' I can see the image.  Why can I not see the image using Vista?

    Start button > in the search box, type options records > press the Enter key > click on view tab > uncheck " always show icons, never thumbnails " > click OK for the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • SQL query to retrieve a single record for each employee of the following table?

    Hi all

    Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.

    CREATE TABLE xxc_contact)

    empnum NUMBER,

    alternatecontact VARCHAR2 (100),

    relationship VARCHAR2 (10),

    phtype VARCHAR2 (10),

    Phone NUMBER

    );

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)

    expected result:

    EmpNum AlternateContact Relationship PhType Phone       

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Thanks in advance.

    994122 wrote:

    Thank you all, that I got a result

    http://www.orafaq.com/Forum/m/620305/#msg_620305

    By Lalit Kumar B...

    Specifically, the two simple solutions provided were:

    1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).

    SQL > column alternatecontact format A20;

    SQL >

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))

    3 FROM xxc_contact one)

    4. WHEN r = 1

    /

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

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

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)

    3 WHERE phone = rn

    4.

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

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

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Kind regards

    Lalit

  • How to count the records for each region day and conditional

    Hello

    I need to create a report where I list activities for a month and the number of specific Type for each days activities. something like below

    Number of days in the month where Type = 'A' Count where Type = B
    January 1, 2009 2 3
    January 2, 2009 7 6
    January 3, 2009 8 7
    ----

    -----
    January 31, 2009 4 6

    I tried with the creation of conditional region for each row of table for every day, but it does not work. I use below for conditional region-

    <? xdofx:If substr (to_date ('20': substr (Planned, 9, 2) |)) » -'|| substr (Planned, 1, 2). » -'|| (substr (Planned, 4, 2), 'MM-DD-YYYY'), 4, 2) = 01? > <? Planned? > <? end if? >
    But it is not functional and do not know how to count records in the table for each date as well.

    Can anyone help in it as soon as possible. I'm quite new to BI.

    Thnks

    You can mark it as resolved... :D

    Kind regards
    Colectionaru

  • After installing firefox os native app appears with a generic icon, which is the same for each of them

    I solve problems reinstall B2G ZTE provider, but all the native application like phone, camera msg etc apperars with a generic icon without staining, it is the same for each of them.

    some app have been updated, i.e. the market and in this case a correct icon appears, but others not update appears with a generic icon uncolored, customized with the name of the application text only.

    my phone provider was movistar, the manufacturer was zte and the model is open from zte.

    I need help to install the correct icons without having to completely reinstall the system if it were possible. Otherwise, the help is to know how to reinstall B2G correct icons

    Hi Josefer,

    I'm sorry to hear that you have problems with your Firefox OS. What are the instructions did you follow to Flash your device ZTE open? Did you receive errors in the process?

    I would say the best way to solve this problem would be to reset your device.

    Warning: Resetting your phone will remove all data stored on the device, including applications, data from the calendar, e-mail accounts and settings.

    To reset the device, follow these instructions:

    1. Open the settings application.
    2. Press the button of device information.
    3. Press the button more than information.
    4. Press the Reset button.
    5. Press OK to continue or Cancel to cancel.

    If the problem persists, you may need to reflash your device using the construction and the instructions available on the download page of ZTE:

    In addition, please remember that the best place to find support for questions specific to the device is directly with the OEM, as they provide the device-specific builds.

    We hope that this problem fixed the problem you had. Please report to us if this helped!

    Thank you!

    -Ralph

  • My Inbox to view the sender for each message and now it does not work... How do I get it back to where it was?

    My Inbox to view the sender for each message and now it does not work... How do I get it back to where it was?

    Right-click on the header at the top of the list of messages and select from the list of options.

  • Petition for grant to display all objects in the DB in the data base and discovers the DOF for each.

    Dear administrators,

    I created the user but now I have a requirement for the granting of privileges to view all objects in the DB in the data base and discovers the DOF for each.

    Any help please

    Ritz

    Thanks to advise all the

  • Where are the files in the tutorial for each tutorials?

    Where can I find the files in the tutorial for each video tutorial under each Adobe application? I know that they exist. However, it is confusing to find.

    Thank you.

    Tutorials Adobe Creative cloud for students | Tutorials Adobe Creative Cloud

  • After purchasing the cloud creative and used for 2 months (for example), so I don't use it for 3 months. How is it? I don't have to pay the tariff for each month, or is it possible to only pay when I use it again? To resume: if I use it for 5 months a

    After purchasing the cloud creative and used for 2 months (for example), so I don't use it for 3 months. How is it? I don't have to pay the tariff for each month, or is it possible to only pay when I use it again? To resume: if I use it for 5 months a year, I have to pay for only those 5 or 12 months?

    No, if you have a subscription according to the type of subscription, you will have to pay each month or year until that you cancel.

    If you think you would use the apps for only three months, then you will not need three months, then our month to month plan would be best for you because it can be cancelled at any time it does not come with an annual contract for more information see the link below

    Adobe - General conditions of subscription

    Kind regards

    Bani

  • PDFMaker, Options, create PDF/A-1 a in Word. Where can I change the setting so I did not check the box for each file, I create?

    PDFMaker, Options, create PDF/A-1 a in Word. Where can I change the setting so I did not check the box for each file, I create?

    Win OS: Windows 7

    Acrobat 9 Pro

    Hello

    You can do this to change the registry settings.

    Go to run type Regedit to open it.

    First make a backup of the registry.

    Here is how do.

    Go to HKEY_CURRENT_USER > software > Adobe > Acrobat > PDFMaker 9.0 > > Word > settings

    You need to change the DWORD values & chain listed below.

    Chain: JobOptions

    Value: PDFA1b 2005 RGB

    DWORD: PDFComplianceIndex

    Value: 1

    DWORD: PDFComplianceLevel

    Value: 1

    Close the registry editor

    Thank you

    Abhishek

  • For all the records for each record double, I need to get a single column with null or 0.

    Hi all

    I have a requirement where I need to get all the records, for each record in double, I need to get a single column with null or 0.

    create table a1

    (

    Identification number,

    VARCHAR2 (100), the point

    part varchar2 (100));

    Insert into a1

    values (1, 'ABC', 'A1');

    Insert into a1

    values (2, 'DEF', 'A2');

    TABLE A

    PART ITEM ID

    1 ABC A1

    1 ABC A1

    1 ABC A1

    DEF 2 A2

    DEF 2 A2

    3 DEF A2

    O/P

    PART ITEM ID

    1 ABC A1

    1        ABC             0

    1        ABC             0

    DEF 2 A2

    2       DEF              0

    3       DEF              0

    Thanks in advance.

    Thanks for your help FrankKalush...

    This one will work.

    WITH got_r_num AS

    (

    SELECT NVL (a1.id, a1.id) as id

    NVL (a1.item, a1.item) AS element

    NVL (a1.part, a1.part) IN the framework

    a1.id AS a_id

    ROW_NUMBER () OVER (PARTITION BY a1.id

    ORDER BY NULL

    ) AS r_num

    BY the a1

    )

    SELECT id

    element

    CASE

    WHEN a_id IS NOT NULL

    AND r_num = 1

    THEN part

    ELSE ' 0'

    END in the framework

    OF got_r_num

    ;

  • Call a procedure only once for the last place of the trigger FOR EACH ROW

    Hello world

    I wonder if someone could help me in the execution of the trigger. My use case what follows:

    -a trigger after each INSERT or UPDATE operation;
    -use FOR EACH ROW algorithm for relaxation;
    -collect certain values inserted/updated fields as: new.uuid and store in a set defined on the layer of the package;
    -only for the last inserted/updated line call a procedure from the global collection with the values collected as a parameter;

    Is it possible to be implemented for the type of the LINE FOR EACH of the trigger? Fact one: new identifier or trigger itself have special attributes such as COUNTY, SIZE to set a size of data inserted or changed to conditional logic? Is there another solution to possible workaround for thoughtful use cases.

    Thank you

    Andrey

    Hi, Andrey,

    I suggest you use 2 triggers:
    (1) A FOR EACH ROW trigger, as you described, to collect relevant data and store it in a temporary table overall or variable poackage. Whenever the trigger is activated, it will overwrite all the data from the previous row.
    (2) AFTER ( NOT FOR EACH ROW) trigger that calls the procedure by using the saved data.

  • How to measure the time for each mapping?

    I use oracle11g with OWB.

    I have several mapping and each dimension tables to update the mapping.

    I want to measure how long it takes to complete each mapping. What is the best way to find the total time for each mapping.

    One way is, we can have POST MAPPING and PROCESS of MAPPING PRE. I can trigger the stored procedure to enter the start time and the end time of each match. On this basis, I can calculate the total time for each mapping. But I have 50 mapping. Now, I need to write 50 different stored procedure and open the POST-PROCESSING of the MAPPING and PROCESS OF MAPPING of the PRE for each mapping. It is complex.

    Is there another way, we enter the total for each mapping of execution? Y at - it that no data in OWF_ MGR dictionary can help on this?

    I would be grateful if someone can help me on this.

    He will remain forever unless you purge it explicitly.

    See you soon
    Katia

  • Do not want multiple windows group in the task bar, I want two icons of TB

    2 questions:

    (1) how can I create several icons in the taskbar to launch firefox?
    I want two to open normal windows and a third to launch a private window. (I have a keyboard shortcut for the window private opening already, but I want in the taskbar)

    (2) I don't want Firefox to group several windows in the taskbar. I wish each window to be its own icon. (Not for each tab, but each window)

    Preventive thanks!

    Of course, it would be one thing to windows instead of one thing to firefox. Don't know what I was thinking yesterday.

    Thank you!

    On Win.8.1, it's as simple as:
    Right-click in the taskbar-->
    -> Properties
    -> The taskbar buttons: never combine.

Maybe you are looking for