Documentation>Application Documentation>XMIM Documentation>XMIM Examples>
Nested Query Example


Nested Query Example
 

The following query illustrates how to have multiple levels in a nested IF-THEN statement. For this example, let's say that you want to see the NG contract of the month for the next year (i.e. for January 2003, show 2004F contract, for February 2003, show 2004G contract, etc.), and also that you want to see it as one continuous column. The example below shows that this can be accomplished with a nested IF-THEN statement.

SHOW
 1: IF
    Date is 1/_/2003
  THEN NG_2004F
  ELSE IF
      Date is 2/_/2003
    THEN NG_2004G
    ELSE IF
        Date is 3/_/2003
      THEN NG_2004H
      ELSE IF
          Date is 4/_/2003
       THEN NG_2004J
       ELSE IF
           Date is 5/_/2003                            
         THEN NG_2004K                            
         ELSE IF                                     
             Date is 6/_/2003                                 
           THEN NG_2004M                                 
           ELSE IF                            
               Date is 7/_/2003  
             THEN NG_2004N                                      
             ELSE IF
                 Date is 8/_/2003                 
               THEN NG_2004Q                                           
               ELSE IF                                                    
                   Date is 9/_/2003                                        
                 THEN NG_2004U
                 ELSE IF      
                     Date is 10/_/2003
                    THEN NG_2004V
                    ELSE IF
                        Date is 11/_/2003
                       THEN NG_2004X
                       ELSE IF
                           Date is 12/_/2003
                          THEN NG_2004Z
                          ENDIF 
                        ENDIF 
                      ENDIF 
                    ENDIF 
                  ENDIF 
                ENDIF 
              ENDIF 
            ENDIF 
          ENDIF 
        ENDIF 
      ENDIF 
    ENDIF 
  WHEN

   Date is 2003