Results 1 to 2 of 2

Thread: Popualtion Columns Conditionally

  1. #1
    Join Date
    Dec 2015
    Posts
    1

    Exclamation Popualtion Columns Conditionally

    I am attempting to modify a simple query. Below is the query:

    SELECT DISTINCT RMAN_SUBJOB_DETAILS_T.DB_NAME, RMAN_SUBJOB_DETAILS_T.INPUT_TYPE, MAX(RMAN_SUBJOB_DETAILS_T.END_TIME) AS "END TIME"
    FROM RMAN_SUBJOB_DETAILS_T
    GROUP BY RMAN_SUBJOB_DETAILS_T.DB_NAME, RMAN_SUBJOB_DETAILS_T.INPUT_TYPE

    The output shows 3 columns: Name, Input type, and max end time.
    I want to write the query so that I can have three different max end time columns (called 'LAST_ARCH_LOG_BACKUP' , "LAST_LEV1_BACKUP", and "LAST_LEV0_BACKUP") these columns will be populated based on one of three input types ("ARCHIVELOG", "DB INCR" and "FULL" repectively. Is there a way to rewrite my query above so that this output is presented as these five columns:

    Name, input type, LAST_ARCH_LOG_BACKUP, LAST_LEV1_BACKUP, LAST LEV0_BACKUP

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Look for CASE statement that allows you to pivot rows into column.

Posting Permissions

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