Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    59
    Provided Answers: 1

    Unanswered: Data Comparability!

    Hello all,

    I am not sure how to implement PL/SQL code to get the sample data to calculate AVG, MAX, MIN score and store them as following format:

    school_id | test_id | course | score | test_date
    --------------------------------------------------
    A | 1 | Math | 70 | 01/01/2012
    A | 1 | Math |100 | 01/30/2012
    A | 2 |Science |65 | 01/01/2012
    A | 2 |Science |40 |01/03/2012
    A | 2 |Science |89| 01/31/2012
    A |3 Biology| 50| 01/15/2012
    A |3 |Biology| 90| 01/30/2012
    A| 4| English| 89| 01/01/2012
    A| 4| English| 50| 01/02/2012
    A| 4| English| 39| 01/03/2012
    A| 4| English| 100| 01/05/2012
    A| 4| English| 89| 01/15/2012
    A| 4| English| 99| 01/17/2012
    A| 4| English| 95| 01/28/2012
    A| 4| English| 100| 01/31/2012

    I would like to get the school monthly report with data as following in

    School_id | Test_id |Course|AVG (score)|MIN (score)|MAX (score)
    ------------------------------------------------------------------
    A | 1 | Math|?|?|?
    A | 2 | Science|?|?|?
    A | 3 | Biology|?|?|?
    A | 4 | English|?|?|?

    Any helps in PL/SQL query, function or stored procedure code are much appreciated. Thanks in advance.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Select school_id, test_id,course,avg(score),min(score),max(score)
    from table1
    group by school_id, test_id,course;
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Dec 2005
    Posts
    59
    Provided Answers: 1
    That what I expect to see. Thanks for your time to help me on query.
    Last edited by avt2k6; 04-03-12 at 00:14.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •