Quantcast
Channel: Toad for Oracle
Viewing all articles
Browse latest Browse all 4009

Forum Post: RE: Pivoting an SQL script that already has pivot

$
0
0
Thanks John for your prompt reply. I followed your suggestion but it did not work. I tried different variations of pivot options. It seems like I am doing something wrong. The modified code is as follows: select PIDM, Gender, College, Major--, UAE_Non_UAE from ( select * from ( select Ou.SGBSTDN_PIDM PIDM, decode(substr(Ou.SGBSTDN_CAMP_CODE,3,1),'M','M','W','W') Gender, STVCOLL_DESC College, STVMAJR_DESC Major, case when STVNATN_NATION = 'United Arab Emirates' then 'UAE' else 'Non_UAE' end as UAE_Non_UAE from SPRIDEN, SGBSTDN Ou, STVCOLL, STVMAJR, GOBINTL, STVNATN where SPRIDEN_PIDM = Ou.SGBSTDN_PIDM and SPRIDEN_CHANGE_IND is null and Ou.SGBSTDN_STST_CODE in ('AS','AW','CW','DA','DW','OW','PA','RA','SP','WN','XP','XT') and Ou.SGBSTDN_TERM_CODE_EFF = ( select max(Inn.SGBSTDN_TERM_CODE_EFF) from SGBSTDN Inn where Inn.SGBSTDN_PIDM = Ou.SGBSTDN_PIDM and Inn.SGBSTDN_TERM_CODE_EFF <= '201610' ) and (Ou.SGBSTDN_COLL_CODE_1 = '05' or Ou.SGBSTDN_MAJR_CODE_1 in ('H094', 'NURS', 'NURB')) and Ou.SGBSTDN_COLL_CODE_1 = STVCOLL_CODE and Ou.SGBSTDN_MAJR_CODE_1 = STVMAJR_CODE and Ou.SGBSTDN_PIDM = GOBINTL_PIDM(+) and GOBINTL_NATN_CODE_LEGAL = STVNATN_CODE(+) ) pivot ( count (PIDM)--, count (Gender) as MW for UAE_Non_UAE in ('UAE' as UAE, 'Non_UAE' as Non_UAE) ) ) pivot ( Count (Gender) --Count (PIDM), --for UAE_Non_UAE in ('UAE' as UAE, 'Non_UAE' as Non_UAE) for Gender in ('M' as M, 'W' as W) ) order by College, Major ;

Viewing all articles
Browse latest Browse all 4009

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>