A Matrix Output for some enthusiastic students

Hi folks,
Greetings. I am trying to create a Matrix Output for some Students who have decided to take Music and/or Sports or neither. I am hoping to break it down by Age and Gender and Interest (Music/Sports).
Any help is greatly appreciated!
Thanks
Scripts to create the tables and INSERT records
create table student_tb(student_id varchar2(4), birth_date date, gender varchar2(1));
create table sports_tb (student_id varchar2(4));
create table music_tb  (student_id varchar2(4));
-- INSERTing into STUDENT_TB
insert into student_tb (student_id,birth_date,gender) values ('1001',to_date('01-JAN-90','DD-MON-RR'),'M');
insert into student_tb (student_id,birth_date,gender) values ('1002',to_date('10-JUL-91','DD-MON-RR'),'M');
insert into student_tb (student_id,birth_date,gender) values ('1003',to_date('01-DEC-90','DD-MON-RR'),'M');
insert into student_tb (student_id,birth_date,gender) values ('1004',to_date('10-AUG-92','DD-MON-RR'),'F');
insert into student_tb (student_id,birth_date,gender) values ('1005',to_date('01-JAN-91','DD-MON-RR'),'F');
insert into student_tb (student_id,birth_date,gender) values ('1006',to_date('01-FEB-91','DD-MON-RR'),'F');
insert into student_tb (student_id,birth_date,gender) values ('1007',to_date('01-AUG-90','DD-MON-RR'),'M');
insert into student_tb (student_id,birth_date,gender) values ('1008',to_date('01-SEP-90','DD-MON-RR'),'F');
insert into student_tb (student_id,birth_date,gender) values ('1009',to_date('01-OCT-90','DD-MON-RR'),'F');
insert into student_tb (student_id,birth_date,gender) values ('1010',to_date('10-MAR-89','DD-MON-RR'),'F');
-- INSERTing into SPORTS_TB
insert into sports_tb (student_id) values ('1001');
insert into sports_tb (student_id) values ('1004');
insert into sports_tb (student_id) values ('1005');
insert into sports_tb (student_id) values ('1009');
insert into sports_tb (student_id) values ('1010');
-- INSERTing into MUSIC_TB
insert into music_tb (student_id) values ('1001');
insert into music_tb (student_id) values ('1003');
insert into music_tb (student_id) values ('1010');
I am hoping to have an Output in this fashion
Please note that I am not intending on adding up the Males and Females on a row by row basis. That's because its the same Student who could be occuring in each Category (MUSIC/SPORTS)
--------- MUSIC -------------------- SPORTS -----------
     Females      Males         Females        Males
Age           
20    0             0              1             0
21    0             0              0             0
22    0             1              2             0
23    0             1              0             1
24    1             0              1             0
My Query - Problem: I clearly have all the data in here but I have lost the information where how many girls or boys are taking Sports, Music or Neither
select age,
       sum(female) female_count,
       sum(male)   male_count,
       count(music_student_id) music_count,
       count(sport_student_id) sports_count
from
  select age, male, female, students.student_id student_id, music.student_id music_student_id, sports.student_id sport_student_id
  from
    select student_id, trunc(months_between(sysdate, birth_date)/12) age,
             case gender
               when 'F' then 1
               else 0
             end
           ) female,
             case gender
               when 'M' then 1
               else 0
             end
           ) male
    from   student_tb
  ) students,
    select student_id from music_tb
  ) music,
    select student_id from sports_tb
  ) sports
  where students.student_id = music.student_id(+)
  and   students.student_id = sports.student_id(+)
group by age
order by age;

SQL> select age,
  2            sum(case when gender='F' and mid is not null then 1 else 0 end) music_females,
  3            sum(case when gender='M' and mid is not null then 1 else 0 end) music_males,
  4            sum(case when gender='F' and sid is not null then 1 else 0 end) sport_females,
  5            sum(case when gender='M' and sid is not null then 1 else 0 end) sport_males
  6  from (
  7  select trunc(months_between(sysdate, a.birth_date)/12) age, a.gender, s.student_id sid, m.student_id mid
  8       from student_tb a, sports_tb s, music_tb m
  9       where a.student_id = s.student_id (+)
10            and a.student_id = m.student_id (+)
11  ) group by age
12  order by age;
       AGE MUSIC_FEMALES MUSIC_MALES SPORT_FEMALES SPORT_MALES
        20             0           0             1           0
        21             0           0             0           0
        22             0           1             2           0
        23             0           1             0           1
        24             1           0             1           0

Similar Messages

  • Why one user can not see plan output for some orgs while other users can?

    We have several inventory/planning orgs. Suddenly one of the users is not seeing any plan output for some organizations. While other users are able to see plan out (planner workbench) for all org.
    All users use the same responsibility.
    Deleted all the folders to eliminate hidden query in default folder.
    Any other thoughts?
    Edited by: 918894 on May 5, 2013 10:22 PM

    The issue is resolved.
    In the user preferences, one user has Inventory Category Set and other user has Planning Category Set as the default. Items belonging to one Org were not assigned Planning Category Set. Thus they were not showing for the other user.
    Thanks for the response.

  • Discoverer Viewer Not retrieving output for some owners

    We migrated to 11g.
    There are some workbook owners as 'sysadmin' and some as users say'XYZ'.
    In the viewer all the reports whose owners are sysadmin, are working fine, but the other ones' are not. I have logged in as sysadmin.
    But in Disco Desktop, all the reports are running fine.

    In the viewer all the reports whose owners are sysadmin, are working fine, but the other ones' are not. I have logged in as sysadmin.Please define "the other ones' are not"? What is the error/issue?
    Thanks,
    Hussein

  • Issue in PDF output for xml report

    Hi,
    I developed one template in RTF and output in pdf is looks fine.
    I have issue in the output, For some invoices i have more lines,when the line details comes to next page for the same invoice i can able to view only the lines information in the next pages for the same invoice without any header details.
    I need header information too if the lines comes to the next page.
    i given <G_Headers> in the top of the page and <End for each> in the end of the page.
    please how to resolve this issue.
    with regards
    Ram

    There are lot of ways of doing this,
    Simple one is given here.
    If you are using table to display the rows, there is option in word table properties, to repeat the header in each page,
    Repeating table headers
    If your data is displayed in a table, and you expect the table to extend across
    multiple pages, you can define the header rows that you want to repeat at the start
    of each page.
    1. Select the row(s) you wish to repeat on each page.
    2. From the Table menu, select Heading Rows Repeat
    Check out in user guide.

  • T COde CS15 : Report is not showing the "Alternative BOM No" for some BOMs

    Hello Guru,
    I am facing a problem for the transaction CS15, when I use this transaction, in the output for some materials, system is not showing "Alternative number" of BOM.
    I cheked Deletion indicator, status of the BOM, validity period etc.
    But unable to get the reason why system is not showing alternative BOM number for the some materials / BOMs.
    Thanks to give your expert comments or solution.
    Thanks in advance
    Hemant

    Hi Hemant,
    please check in CS02 if those top level BOm's which dont show alternative BOm number in CS15, do they really have alternatives?
    the most probale reaosn why alternative is not shown is they dont have any alternate BOM or they are variant BOMs.
    please check.

  • I buy adobe creative suite for teachers and students about one year ago but now i'm not longer a student. Can I still use this programs legally for commercial purposes or do I have to buy some upgrades or something like this? Please help

    I buy adobe creative suite for teachers and students about one year ago but now i'm not longer a student. Can I still use this programs legally for commercial purposes or do I have to buy some upgrades or something like this? Please help

    The license did not have use restrictions Licenses and terms of use | Adobe
    BUT... when your one year Education account ends, I do not think you will be able to renew at the Education rate

  • Multiple ipad Carrying case? Looking for some form of a case where elementary students can transport 20 ipads safely up or down staircases

    I am a teacher and my building just purchased a set of 25 ipad 2s.  I am looking for some form of a carrying case where a teacher or students can take 20-25 ipads from the iPad storage cart and carry it to the classroom.  Some classrooms are on the second floor so something that would hold them safely would be great. Thanks for the help!!

    Check out the carts on this page.  Great ways to spend taxpayer dollars!
    http://www.apple.com/education/labs/
    An Apple iPad Learning Lab streamlines the management of classroom sets of iPad devices. Each lab includes 10 iPad devices and a sturdy and secure mobile cart. The cart can store, charge, and sync up to 30 iPad devices and has room for a MacBook computer. The cart rolls easily around campus, so multiple classes can benefit, and it can be locked to secure the devices when they’re not in use. For even more iPad portability, the Bretford PowerSync Tray can charge, sync, store and secure up to 10 iPad devices at once and is available only through Apple. Purchase a predesigned Apple iPad Learning Lab or let us help you build your own iPad mobile lab.

  • Output type in Purchase Orders, erroring out for some users

    Hi All,
    We have a custom ouput type for PO, say 'ZZZ'. The problem is we do not get this out put type in the message screen of PO for some users and some time it gets populated for the same users. Please help me in understanding this issue as we are unable to track the things.
    Thanks,
    Amit

    Hi
    Please check the maintenace of the condition record, Check the key combination used. The conditon records are mainatined based on the organisational parmeters & the Vendor data.
    Please check the PO's in whcih the message are not coming automatically & check the combination exist or not as condition records.
    You can check the condition records using MN05, MN06
    Award points if useful
    Thanks & Regards
    Kishore

  • Best Output for DVD from FCP???

    I'm a newbie and need help. I was outputting from FCP 6.0.4 using Export > QuickTime Movie, then importing that file into DVD Studio Pro. But, a college student who saw it recommended Exporting using Compressor 3.0.3 which I did using the DVD: Best Quality 90 Minutes. I noticed an improvement in my DVD quality, however, in every program I've tried and retried so far I get a little short segment (about a 10 second portion) in my half hour long program that all of the sudden goes crazy with distortion and pixelization and image irratic jumping movements. What can I do to create a totally smooth video when going from FCP to Compressor or is there a better way to finally get it into DVD Studio Pro? I want the highest quality solution as the video footage is originally HD. Thanks for your help, Desperate Russ

    coyotegyrl333 wrote:
    For some reason, I've always found this to work:
    render your project and make sure you have only one
    video track in the timeline. Drag existing sequences into
    a new one so that you accomplish this. Render.
    Restart the computer.
    Export using compressor.
    Maybe this is mumbo-jumbo, but it works every time for me.
    good luck to you.
    The advice is more or less sound but you have several unnecessary steps. Your idea is to consolidate all of the FCP timelines and their associated media into a single timeline; you are nesting the project.
    Forcing everything to render is good.
    Export the entire project as a self contained movie.
    Import the self contained movie into DVDSP.
    You would perform these steps with each of the individual movie clips you want to have as menu items in your DVD project. Maybe. You might be able to use one single large movie and set go-tos for each chapter. Whatever.
    But there is no reason to restart your computer.
    And there may be no good reason to use Compressor to create the MPEG2 files.
    bogiesan

  • How can I change the output for certain columns only?

    I am finding it hard to explain my issue , as I am very green when it comes to database, but I will try my best.
    I am writing a script that will query a database and output 5 columns, the first and last name of a student, the last name of their adviser, their enrollment status, and how many years they have been enrolled.
    I have the student's enrollment date and graduation date stored, however not all students have graduated, so that field is null for some students.
    my question is, how can I use their enrollment status of graduated to change the calculation of how long they were enrolled for.
    This is what I have so far :
    SELECT
         STUDENTS.NameFirstS,
         STUDENTS.NameLastS,
         STUDENTS.EnrollStatus,
         TRUNC((MONTHS_BETWEEN(SYSDATE, STUDENTS.EnrollDate))/12) as Years,
         FACULTY.NameLast
    FROM
         STUDENTS,
         FACULTY
    WHERE
         STUDENTS.ThesisAdvisor = FACULTY.FacultyId
    I'm not sure where to go form here, like I said, I am very new. Thank You in advance!

    Thank you for the warm welcome :)
    My Oracle Version is 11.2.0.1.0
    Here is the create statement I used for the table.
    CREATE TABLE STUDENTS
    (StudentId NUMBER(9)                                                             
    ,NameFirstS VARCHAR(255) NOT NULL                                             
    ,NameMiddleS VARCHAR(255)                                                       
    ,NameLastS VARCHAR(255) NOT NULL                                             
    ,PhoneHome NUMBER(10) NOT NULL                                                  
    ,PhoneOffice NUMBER(10)                                                            
    ,HomeCity VARCHAR(255) NOT NULL                                         
    ,HomeState VARCHAR(255) NOT NULL                                             
    ,HomeStreet VARCHAR(255) NOT NULL                                             
    ,EnrollDate DATE NOT NULL                                                       
    ,EnrollStatus VARCHAR(255) NOT NULL                                             
    ,StudyArea VARCHAR(255) NOT NULL                                             
    ,SpouseNameFirst VARCHAR(255)                                                  
    ,SpouseNameLast VARCHAR(255)                                                  
    ,ThesisTitle VARCHAR(255) NOT NULL                                             
    ,ThesisInternational VARCHAR(255)                                              
    ,ConvocationDate DATE                                                            
    ,ThesisAdvisor NUMBER(9) NOT NULL                                             
    ,Mentor NUMBER(9) NOT NULL                                                       
    ,CONSTRAINT STUDENTS_pk PRIMARY KEY (StudentId)                              
    ,CONSTRAINT STUDENTS_Mentor_fk FOREIGN KEY (Mentor)                     
    REFERENCES FACULTY(FacultyId)                               
    ,CONSTRAINT STUDENTS_ThesisAdvisor_fk FOREIGN KEY (ThesisAdvisor)     
    REFERENCES FACULTY(FacultyId)                                                       
    And here is 2 inserts of random data
    INSERT INTO STUDENTS (StudentId, NameFirstS, NameMiddleS, NameLastS, PhoneHome, PhoneOffice, HomeCity, HomeState
    , HomeStreet, EnrollDate, EnrollStatus, StudyArea, ThesisTitle, ConvocationDate, ThesisAdvisor, Mentor)                               
    VALUES(778506631                                        
              , 'John'                                             
              , 'Jacob'                                        
              , 'Smith'                                             
              , 3125551234                                        
              , 5182293313                                        
              , 'Wilksbury'                                        
              , 'Texas'                                             
              , '14 Main Road'                                   
              , TO_DATE('04-SEP-2003', 'DD-MON-YYYY')          
              , 'Graduated'                                        
              , 'Physics'                                             
              , 'Why Move'                                        
              , TO_DATE('07-JUL-2008', 'DD-MON-YYYY')          
              , 157928743                                             
              , 997569876                                        
    INSERT INTO STUDENTS (StudentId, NameFirstS, NameLastS, PhoneHome, HomeCity, HomeState, HomeStreet
    , EnrollDate, EnrollStatus, StudyArea, SpouseNameFirst, SpouseNameLast, ThesisTitle, ThesisInternational, ThesisAdvisor, Mentor)
    VALUES(251321188                                             
              , 'Larry'                                             
              , 'Timsfield'                                        
              , 2815551200                                        
              , 'Johnsburg'                                        
              , 'Florida'                                             
              , '223 Route 54'                                   
              , TO_DATE('09-SEP-2010', 'DD-MON-YYYY')          
              , 'Full Time'                                        
              , 'Medicine'                                        
              , 'Wanda'                                             
              , 'Timsfield'                                        
              , 'Cut Me Mick'                                        
              , 'Yes'                                                  
              , 997569876                                             
              , 101325587                                             
    I don't know how to format them like you did in your reply, so they look like a quote, so I hope that just pasting them in is okay.

  • Adobe Premiere Pro CC launches for some users, but crashes for others.

    I am troubleshooting an issue in a college computer lab. Adobe Premiere Pro CC launches perfectly for some users, but crashes for others. All computers are joined to a domain. The program launches successfully under faculty and admin accounts. It launches under my student account and will launch for some students in the class. There are, however, some students who cannot get the program to launch. Each time it fails when attempting to load ImporterQuickTime.prm.
    For these students, the following error appears:
    Adobe Premiere Pro CC has stopped working
    Check Online for a solution and close the program (Tried this nothing seems to come of it)
    Close the program
    I clicked View problem details
    Problem Event Name: APPCRASH
    Application Name: Adobe Premiere Pro.exe
    Application Version: 7.2.2.33
    Application Timestamp: 532c3999
    Fault Module Name: dvaui.dll
    Fault Module Version: 7.2.2.33
    Fault Module Timestamp: 532bed86
    Exception Code: c0000005
    Exception Offset: 00000000002d31c1
    OS Version: 6.1.7601.2.1.0.256.48
    Locale ID: 1033
    Additional Information 1: 3272
    Additional Information 2: 32722596c6b4441ac0840ed9743cbfbb
    Additional Information 3: 3e22
      Additional Information 4: 3e2260f0a53760c20f23c7e2675c1736
    I did check Quicktime and it is not updated to the most recent version. However, if it was a result of Quicktime not being up to date, why can some accounts launch the program while others cannot. I have also updated the graphics driver on one computer. No change. I compared my student Active Directory account to that of one student who could not launch the program. They are in exactly the same place in AD and therefore have the same permissions on the domain. This is a puzzling issue and the instructor is getting frustrated. Any help or suggestions with this matter would be greatly appreciated.
    -Barb

    I have no idea, other than what I said about the program's design requirement for an Admin account and "sometimes" problems on any other account
    About the only thing I can suggest is a "remote control" chat session... when a student with a non-working account is having problems
    Creative Cloud chat support (all Creative Cloud customer service issues)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • VLD-1119: Unable to generate Multi-table Insert statement for some or all t

    Hi All -
    I have a map in OWB 10.2.0.4 which is ending with following error: -
    VLD-1119: Unable to generate Multi-table Insert statement for some or all targets.*
    Multi-table insert statement cannot be generated for some or all of the targets due to upstream graphs of those targets are not identical on "active operators" such as "join".*
    The map is created with following logic in mind. Let me know if you need more info. Any directions are highly appreciated and many thanks for your inputs in advance: -
    I have two source tables say T1 and T2. There are full outer joined in a joiner and output of this joined is passed to an expression to evaluate values of columns based on
    business logic i.e. If T1 is available than take T1.C1 else take T2.C1 so on.
    A flag is also evaluated in the expression because these intermediate results needs to be joined to third source table say T3 with different condition.
    Based on value taken a flag is being set in the expression which is used in a splitter to get results in three intermediate tables based on flag value evaluated earlier.
    These three intermediate tables are all truncate insert and these are unioned to fill a final target table.
    Visually it is something like this: -
    T1 -- T3 -- JOINER1
    | -->Join1 (FULL OUTER) --> Expression -->SPLITTER -- JOINER2 UNION --> Target Table
    | JOINER3
    T2 --
    Please suggest.

    I verified that their is a limitation with the splitter operator which will not let you generate a multi split having more than 999 columns in all.
    I had to use two separate splitters to achieve what I was trying to do.
    So the situation is now: -
    Siource -> Split -> Split 1 -> Insert into table -> Union1---------Final tableA
    Siource -> Split -> Split 2 -> Insert into table -> Union1

  • How can I make Apple Earphones be the Input and Output for Audio

    I have some older headphones and they aren't compatible with a Mid 2010 (Intel Core i3) 21.5 Inch iMac
    Is there some way to make Apple Earphones be the Input and Output for Audio in the iMac
    This is a problem for me personally as when I am talking to someone on Skype the iMac picks up the In-built Microphone audio, and yes the headphones I'm using do work straight from the iMac as audio output
    Any help is appreciated

    you can connect the headset to something like this
    http://www.ebay.com/itm/NEW-MaelineA-3-5mm-Female-to-2-Male-Gold-Plated-Headphon e-Mic-Audio-Y-Splitter-/381100440348
    and then connect the mic to the input and the headset to the headset port

  • With 10.2 I can only use system speaker output for audio, NOT my RME FF400 I used previously. The FF400 works fine with other apps. How can I set this device in FCP 10.2? (it is set in both system preferences and midi)

    With 10.2 I can only use a system (e.g. speaker) output for audio, NOT my RME FF400 I used without any problems previously. The FF400 works fine with other apps (some like TwistedWave) setup in the program, and others (like Spotify) using system preferences & audio midi setup. How can I set the FF400 to be the sound output device in FCP 10.2? N.B. The FF400 is set as sound output device in both system preferences and audio midi setup.

    From the fcp.co forum. See if this does anything for you.
    simon_hutchings
    OFFLINE
    Junior Boarder
    Posts: 24
    Thank you received: 5
    Karma: 1
    I have the solution! Well it at least worked for me. This is the response I got from Apple, Can you please try the following steps towards fixing your audio issue, and report back with your results?
    1. Open the application Audio Midi Setup (located in Applications : Utilities)
    2. Select the Output Tab for the current output device
    3. Select the Configure Speakers option
    4. Select the Multichannel tab
    5. Change the setting to Stereo Now mine was set to stereo but the left channel wasn't showing left. re-clicking on stereo reloaded the settings and after clicking apply it worked. 

  • How to set Display Only for some records in CAT2 Worklist

    Hi,
    I have a requirement to modify an attributes for some records in the Worklist of CAT2.
    We have an external system where we book our time. Weekly we import data from that external system into CATSDB using BAPI for every single employee.
    We would like when the user wants to modify his time sheet to be able to add/modify all records except those which were imported from the external system. Which means that those records should be in Display only mode / grayed out / before release.
    Is there any user exit or BADI that could help to modify that attribute and that will be triggered before displaying the Worklist ?
    Please advise !
    Thanks,
    Stefan

    I've solved the problem.
    First I've added customer field in CI_CATSDB structure and when I am importing the data I am populating that field with 'X', which means that this is record from the external application.
    I've created enhancement implementation in Function group->CATS, screen->2003 MODULE->D2000_MODIFY_LOOP, subroutine->modify_d2000_loop where I am checking the field mentioned above if it is 'X' I am modifying the screnn-output = off.
    It works, thak you for your help.
    Regards,
    Stefan

Maybe you are looking for

  • Audition 1.5 and E-Mu Patchmix DSP

    Hi, I've got a problem using Audition 1.5 with the Patchmix DSP software that came with my E-Mu 0404 sound card.  I know that lots of people have issues with this software, but I've done some searching and can't come up with the answer to my problem.

  • Why did I switch?

    We had two flip phones thru Verizon.  Used it for phone calls only, any text separate charge.  In nov I purchased I phone 5s.  Continued the same phone service with verizon.  I used my wifi thru my land line phone service.  I was getting my land line

  • I wish to get the game Word Mole on my Blackberry Pearl

    I wish to get the game Word Mole on my Blackberry Pearl

  • How to enlarge text in reader mode in safari on iOS 7?

    Hi all, Just wondering if anybody could tell me how to enlarge the text when in reader mode on Safari in iOS 7? Before in iOS 6 this was very easy; you just needed to press an icon that had bigger text display while in reader mode itself. But now it

  • How to get count of group of current login user if AD Group is added in SharePoint Group?

    My Client has 2 SharePoint Application. For the AD Users they have created AD Group and added users in that AD Group as per requirement. Later AD Group is added in SharePoint Group. When I'm trying to fetch Current User Group count, I can able to get