Separate values for the pre-treatment and results of the comprehensive review (without using the PL/SQL)

Hi people,
This year was difficult because it does not clearly justify what I want to achieve. The main reason for me to try this approach is to reduce the time of the performance. I have my program works very well, but since it accesses a view for each student, slows down the performance.

Purpose of this report: Show all Dates of examination for students, but only to display the results pre and review of the overall assessment on the first line for students.

Table scripts and INSERT statements:
create table STUDENT_TB(student_id varchar2(4), last_name varchar2(20), first_name varchar2(20), evaluation_date date);
create table EXAM_TB(student_id varchar2(4), exam_date date, result number);
create table EVALUATION_TB(student_id varchar2(4), eval_flag varchar2(1), sampling_date date);

insert into STUDENT_TB values('1001', 'Poppins', 'Mary', to_date('27-SEP-2012', 'DD-MON-YYYY'));
 
insert into EXAM_TB values('1001', to_date('20-APR-2011', 'DD-MON-YYYY'), 30);
insert into EXAM_TB values('1001', to_date('20-MAY-2012', 'DD-MON-YYYY'), 39);
insert into EXAM_TB values('1001', to_date('10-JUL-2012', 'DD-MON-YYYY'), 34);
insert into EXAM_TB values('1001', to_date('10-SEP-2012', 'DD-MON-YYYY'), 39);
insert into EXAM_TB values('1001', to_date('01-DEC-2012', 'DD-MON-YYYY'), 82);
 
insert into evaluation_tb values('1001', null, to_date('22-APR-2011', 'DD-MON-YYYY'));
insert into evaluation_tb values('1001', 'N', to_date('20-JUL-2012', 'DD-MON-YYYY'));
insert into EVALUATION_TB values('1001', 'Y', to_date('10-DEC-2012', 'DD-MON-YYYY'));
Desired output:
SID     Last Name   First Name   Evaluation Date    Exam Date   Results   Order   Pre Evaluation   Overall Evaluation   Accept?
===============================================================================================================================
1001     Poppins         Mary      27-SEP-12         20-APR-11     30       1           N                       Y            Y
1001     Poppins         Mary      27-SEP-12         20-MAY-12     39       2
1001     Poppins         Mary      27-SEP-12         10-JUL-12     34       3
1001     Poppins         Mary      27-SEP-12         10-SEP-12     39       4
1001     Poppins         Mary      27-SEP-12         01-DEC-12     82       5
Business rules:
The Pre, global assessment and accept it? fields are derived. The area of the pre assessment is derived from the EVALUATION_TBtable. Its the value of eval_flag where sampling_date < = evaluation_date.
In our example, the pre assessment should be an "n" while the overall assessment must be a 'Y '. The priority is Y-> N-> Null. The Accept flag is set to a 'Y' If a meadow at overall results past of N to Y or a NULL of Y value.

I have to return all the lines for the student that show the results of the reviews SQL is the following:
I need to join the view EVALUATION_TB. Simply join them of course would be a resulting vector product in 15 files that I don't want. I tried online (subqueries) but I failed again. Any help would be great!
I created the column ord_num to maybe help using only this folder to display the results of the assessment.
select x.student_id, x.last_name, x.first_name, x.evaluation_date,
       m.exam_date, m.result,
       dense_rank() over (partition by x.student_id order by m.exam_date) ord_num
from
(
  select  s.student_id, s.last_name, s.first_name, s.evaluation_date
  from    student_tb s
) x, exam_tb m
where x.student_id = m.student_id (+);

SID     Last Name   First Name   Evaluation Date    Exam Date   Results   Order
===============================================================================

1001     Poppins     Mary     27-SEP-12     20-APR-11     30     1
1001     Poppins     Mary     27-SEP-12     20-MAY-12     39     2
1001     Poppins     Mary     27-SEP-12     10-JUL-12     34     3
1001     Poppins     Mary     27-SEP-12     10-SEP-12     39     4
1001     Poppins     Mary     27-SEP-12     01-DEC-12     82     5
Thank you!

Published by: Roxyrollers on March 14, 2013 11:37

Published by: Roxyrollers on March 14, 2013 11:38

Published by: Roxyrollers on March 14, 2013 12:27

Published by: Roxyrollers on March 15, 2013 13:43

Hi Roxyrollers,

Please check your insert statements before posting. They have syntax errors.

The following query is to give you the desired result:

with pre_eval as
(
   select e.student_id
        , max(e.eval_flag) keep(dense_rank last order by e.sampling_date) eval_flag
     from evaluation_tb e join student_tb s
          on e.student_id=s.student_id
             and e.sampling_date <= s.evaluation_date
   group by e.student_id
)
,all_eval as
(
   select e.student_id
        , max(e.eval_flag) keep(dense_rank last order by e.sampling_date) eval_flag
     from evaluation_tb e join student_tb s
          on e.student_id=s.student_id
   group by e.student_id
)
, data_with_rank AS
(
   select s.student_id, s.last_name, s.first_name, s.evaluation_date
        , m.exam_date, m.result
        , dense_rank() over (partition by s.student_id order by m.exam_date) ord_num
     from student_tb s
          left outer join exam_tb m
          on (s.student_id = m.student_id)
)
select s.student_id, s.last_name, s.first_name, s.evaluation_date
     , s.exam_date, s.result
     , e.eval_flag as pre_eval
     , a.eval_flag as overall_eval
     , case when a.eval_flag='Y' and e.eval_flag!='Y' then 'Y' end accept
  from data_with_rank s
       left outer join pre_eval e
          on (s.student_id = e.student_id and s.ord_num=1)
       left outer join all_eval a
          on (s.student_id = a.student_id and s.ord_num=1)
order by s.student_id, s.exam_date;

STUDENT_ID LAST_NAME            FIRST_NAME           EVALUATION_DATE EXAM_DATE     RESULT PRE_EVAL OVERALL_EVAL ACCEPT
---------- -------------------- -------------------- --------------- --------- ---------- -------- ------------ ------
1001       Poppins              Mary                 27-SEP-12       20-APR-11         30 N        Y            Y
1001       Poppins              Mary                 27-SEP-12       20-MAY-12         39
1001       Poppins              Mary                 27-SEP-12       10-JUL-12         34
1001       Poppins              Mary                 27-SEP-12       10-SEP-12         39
1001       Poppins              Mary                 27-SEP-12       01-DEC-12         82                                                                          

However, is not clear to me why the assessment are related only to the first line in the query.
The evaluation_tb table is in fact related to student_id and I expect to be connected all lines.

I've actually linked subqueries pre_eval and all_eval only in line with rank = 1 but I don't understand if that's correct according to business requirements.

Kind regards.
Al

Published by: Alberto Faenza on 14 March 2013 20:29
ORDER BY added, deleted ord_num output

Tags: Database

Similar Questions

  • [ADF, JDev12.1.3] (How to set values for the attributes 1) to create a file and 2) committing to the database?

    Hallo,

    in my tables and forms (created from VO istances) there are some areas for which, insert and update, I calculate and set the value programmatically when a record is created or updated.

    In some cases, I put the necessary values using the 'CreateWithParams' in the workflow diagram...

    In some other ones, I associate an action, a bean, a created button drag-and - drop operation 'CreateWithParams' of the istance VO...

      public String cwpButton_action() {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("CreateWithParams");
        // here I calculate and set the needed params
        // ...
        Object result = operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
          return null;
        }
        return null;
      }
    

    And is ok if I can calculate the values for the attributes before a new record is created.

    But the approach that I have used to define the attributes (for new and updated records) whose value should be caluclated after the user has filled in the fields, before committing to the database?

    Thank you

    Federico

    Federico,

    Let me first tell you that our code is activity masking errors (the cache instead of working on them).

    1. If (! operationBinding.getErrors () .isEmpty ()) {}
    2. Returns a null value.
    3. }
    4. Returns a null value.

    This means that you do not check the errors at all. You must at least print a log with the error message, you receive, if you get one!

    To solve your problem, you override the method prepareForDML() of the entity or entities in question. You can calculate and set the necessary attributes until they get engaged in the doDML(). Do not use doDML() because it is too late in the life cycle.

    Timo

  • How can I add a separate apple for the iphone and ipad wife id

    How can I add a separate apple for the iphone and ipad wife id

    Hi, are the measures already implemented? If they are, you need to configure them again and establish a Apple ID at this time.

    Apple ID - Support official Apple

  • Definition of default values for the inputs of button and the cursor?

    Hello

    I use Labview 8.5.1 and have a few entries button and zipper-type on my front. How can I set some of them having specific (as opposed to zero) default values when the VI is executed?

    Thanks for the help

    The default value for the type of slide of entry (or button).

    Right-click on the control.

    Select "Operations on the data" > "default to the current value of doing."

  • I have a subscription Adobe CC and then Adobe CS6 with a separate license. In addition, I also have a separate license for the stand-alone Adobe Lightroom version.  These were installed on separate computers, however no opf the versio of stand alone

    I have a subscription Adobe CC and then Adobe CS6 with a separate license. In addition, I also have a separate license for the stand-alone Adobe Lightroom version.  These were installed on separate computers, however no opf the stand-alone version will work now that I get a box for Creative cloud telling me that I have the software on two computers and I have to disconnect from the other computer.  How can I fix so that I mustn't keep disconnection in order to work on my laptop, etc. ? I have a subscription to the program and three separate license for each other. When he told me to update the program he changed everything to CC, which I did not intend to do.

    HI ProfWSA,

    I see that you have a subscription active creative cloud.

    I beg you sure you want to contact adobe help support:

    Contact the customer service

  • Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.

    Is there a default value for the color management in PSE10? Beautiful photos from iPhoto, but blur with elements. I need help with this before as I consider that the upgrade to PSE13 and beyond.

    Printing which forms an angle seems ok, but one that is horizontally seems faded, incomplete.

    I was wondering if I saved a layer somewhere and set it as a default value.

    If you group the layers, you will be left with a single layer, thus spreading your concern.

    Suggest that you do the following:

    1. Make sure you have the latest drivers for your printers
    2. Reset the default preferences.

    Hold the Alt, Ctrl + Shift keys when you click the icon to open the items. When asked if you want to delete the settings file, say Yes.

    Items nearby and let regenerate the file.

  • We have suite adobe and want to own separate items for separate individuals for the part of the suite that's ok?

    We have license to adobe eLearning suite and want to own separate items for separate individuals for the part of the suite that's ok?  the principal owner doesn't use the photoshop person, but we want to let someone else in our group to use the part

    No, only the licensee is legally authorized to use their purchased product.

  • failed to create value for the message Analyzer "at line 54.

    I get the following error, can someone please?

    failed to create value for the message Analyzer "at line 54.

    Hi ejpeppjep,

    Check if this article helps you fix the problem: http://support.microsoft.com/kb/823768

    If the problem persists, we recommend that you try the following steps and check the result.
    Step 1: a. Click Start, click Run, type cmd and click ok.
    b. at the command prompt, type sfc/scannow and press ENTER.
    c. once the analysis is complete, restart the computer and check if the problem persists.

    Note: You will be asked to insert the Windows XP disk, if a file is missing.

    For more information, see Description of Windows XP System File Checker (Sfc.exe)

    Step 2: If the problem persists, restore the computer to an earlier time
    see How to restore Windows XP to a previous state .

    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Multiple values for the same column in the columns of diffétent in the same row?

    Hi all
    I wonder how you can display different values for the same column in different columns on the same line. For example, using a CASE statement, I can:

    CASE WHEN CODE IN ('1 ', ' 3') THEN COUNT (ID) AS 'Y '.
    CASE WHEN CODE NOT IN ('1 ', am') THEN COUNT (ID) AS "N".

    Yes, that will produce two columns but will produce null values to empty and also two separate registers.


    Any ideas?

    Thank you

    Are you sure that this code works for you?

    Select ID
             ,CASE WHEN MODE_CODE IN ('1', '3') THEN COUNT( No) END as "Fulltime"
             ,CASE WHEN MODE_CODE NOT IN ('1', '3') THEN COUNT( No ) END  as "Other"
    From table
    group by ID
    

    I guess the code above fails because MODE_CODE is not in your group by?

    My suggestion would be to put the CASE in the COUNT:

    Select ID
             ,COUNT(CASE WHEN MODE_CODE IN ('1', '3') THEN No END) as "Fulltime"
             ,COUNT(CASE WHEN MODE_CODE NOT IN ('1', '3') THEN No END)  as "Other"
    From table
    group by ID
    

    CASE expressions return no. when the respective conditions are true and NULL otherwise.
    COUNTY will have non-null values.

  • How to find out the ASCII values for the Spanish character

    Hello

    I had an obligation to maintain the Spanish character and must also always records based on the Spanish character.

    Kindly guide me for below.

    To filter the records that contains Spanish characters?
    To get the ASCII values for the particular column?

    For example, we can find the ASCII value of 'a' using the select syntax ASCII('a') double.

    But I want to find the value of the particular column ASCII values. That is to say. name.
    For example, the customer name is 'Suresh', I want the ASCII values for the entire name of 'Suresh '.

    Please do the necessary help / advice on that.

    Thank you
    Orahar

    To expand on what I said in my first post, you want to do something in this direction:

    with t (thename) as
      (
      select 'Suresh' from dual
      )
    select thename
         , substr(TheName, level, 1)
         , ascii(substr(thename, level))
      from t
    connect by level <= length(thename);
    

    The result of the above query is:

    THENAM S ASCII(SUBSTR(THENAME,LEVEL))
    ------ - ----------------------------
    Suresh S                           83
    Suresh u                          117
    Suresh r                          114
    Suresh e                          101
    Suresh s                          115
    Suresh h                          104
    
    6 rows selected.
    

    Note that the WITH statement is only there to simulate a table for this example. With a table, all you do is get rid of the with and replace it with the name of "t" for your table name (also the name of the column with name column has in your table).

    Finally, I suggest that you post your question with, an example of table and the output you want for PL/SQL forum. There are people out there who will give you all sorts of ways to solve this problem.

    HTH,

    John.

  • DEU-00014: invalid value for the setting, "include".

    Hi, I need to do an export of paintings from a schema and a particular query executed will apply to all the specified tables in "INCLUDE = TABLE: '('TBL1', 'TBL2') IN' in the command expdp.»

    Now, I get the question in this setting INCLUDE. I have about 200 paintings to be included and I add this parameter INCLUDE in a separate parameter with all table names 200 file in Informatics and with the help of this parameter file in the expdp command.

    Error message I get:
    DEU-00014: invalid value for the setting, "include".

    When I use the same process for 2 tables, this works very well. I think that there is a limit to the number of characters that can be used in the INCLUDE parameter. If so, then how do I use expdp to select only those 200 tables of 500 paintings in my diagram. I'd appreciate any help on this. Thank you.

    Hello

    I'm sure that the limit is 4000 characters, but there are fairly simple workaround.

    Create the table my_tabs (a varchar2 (30));
    insert into my_tabs values ('your_table_name');
    Repeat this step for each of your 200 tables

    include = TABLE: "in ((SELECT from MY_TABS)) '"

    You may need to mess you with the quote, but the value you were using is just an expression. It is only by using a different expression.

    Dean

  • How can you specify the default value for the undefined array elements

    According to aid LV, the tables have two default values, the normal default value and the default value for the undefined array elements.

    I assume that there must be a way to specify the default value for later, but I can't find it anywhere.  Any ideas?

    I know that you can drag the item out of the table container.  Change the default value on this scalar element.  Then drag the item in table tank.

  • Essbase Warning (1023135) skip certain values for the replication

    Hello

    When you replicate the complete data of a partition Essbase BSO in Essbase ASO (11.1.2.2),
    thousands of warning messages are logged in the application log:

    "Warning (1023135) skip certain values for the replication.

    The partition (data of level 0) valid and the counties of cells in each area are exactly.

    No idea of the possible causes and consequences?

    Thanks for your help.

    Philippe Cuisset

    Hello

    Thanks to the contributors.

    The contours of the source and the corresponding target, with the exception of 3 members with different names in the source and target.
    My score has 2 spaces for these 3 members. Mapping advanced between the names of source and target members has been set in a field, but it was missing in the other (not detected by the validation of the partition!). I don't set it too and now no more warnings.

    Philippe Cuisset

  • When you create a PDF from a scanner, is there a way to set the default value for the size of 8.5 x 11 letter custom every time I make a PDF from a scanner?

    When you create a PDF from a scanner, is there a way to set the default value for the size of 8.5 x 11 letter custom every time I make a PDF from a scanner?

    Hi kevin7frg,

    You can go to "file > create > scanner > configure presets PDF»

    The dialog box that appears, you can choose 8.5 X 11 as the default width and height of PDF pages to scan.

    Hope that helps.

    Kind regards

    Ana Maria

  • How to add the default value for the "Full - Text Search" box

    Hi all

    I am looking for the ability to add a default value for the "Full text search" box in the search form.

    Example:

    When the user accesses the search page it get default values for some fields (defined in the rule as default values) such as

    xField1 = txt1 and xFiel2 = txt2.

    and Furthermore we need full-text = Hello world.

    Is this possible?

    Another way that we use is to open the search by URL with coreContentOnly = 1 as a form:

    http:// < Server >/cs/idcplg? IdcService = GET_DOC_PAGE & to Action = GetTemplatePage & to Page = STANDARD_QUERY_PAGE & coreContentOnly = 1 & to xField1 = txt1 & to xFiel2 = txt2

    It is possible to add full-text criteria here? Somethig like: & text = Hello World

    Thank you

    Leon

    It is not possible in a very obvious way, not to mention that it is a rather strange request.  I can't really imagine a realistic use for this case.

    Anyway, without a messy customization, you should provide a default query with an FTX inside element text setting (i.e. "IdcService = GET_DOC_PAGE & Action = GetTemplatePage & Page = STANDARD_QUERY_PAGE & QueryText =Hello World" "")

    To do this in a profile in the secondary effects of the profile section, add the following:

    <$dpPromote("QueryText",>Hello everyone") $>.

Maybe you are looking for