4 Replies Latest reply: Jul 4, 2013 10:07 AM by Anders Moller RSS

    Filter results of column alias in SELECT statement

    Robert Fishel

      Hello my friends.  I have been unable to figure out this problem.  I am trying to filter the SAPMERCHVDIVISIONCODE alias in the statement below.  I only want data with a value of 806 in this column.  Is it possible to do within the same statement?  If not, what would the separate statement look like.  Thanks so much!!

       

       

      SQL Select 
          PSPLN As TASK, 
          PSCASN, 
          PSSEA, 
          PSLTYP, 
          PSAREA, 
          PSZONE, 
          PSAISL, 
          PSBAY, 
          PSLEVL, 
          PSPOSN, 
          PSSYR, 
          PSSTYL, 
          PSSSFX,
          CAST(LEFT(PSSYR || PSSTYL || PSSSFX,3) AS INTEGER) AS SAPMERCHDIVISIONCODE,
          PSSYR || PSSTYL || PSSSFX AS SKU,
          PSSZDS, 
          PSSQTY, 
          PSQPUL, 
          PSRLOC, 
          PSSTAT, 
          PSDCR, 
          PSCRT,
          PLWHSE,
          CASE PLWHSE 
              WHEN '001' 
                  THEN TRIM(PSAREA) || TRIM(PSZONE) || Left(TRIM(PSAISL),1) || Right(TRIM(PSAISL),1) || TRIM(PSBAY)
              WHEN '003' 
                  THEN TRIM(PSAISL) || TRIM(PSLEVL) || TRIM(PSPOSN)
              ELSE TRIM(PSAISL) || TRIM(PSLEVL) || TRIM(PSPOSN) 
          END AS RESERVELOCATION
          From PKMANH221D.PSPULL00 A, PKMANH221D.PLPULL00 B
      Where A.PSPLN = B.PLPLN
      And A.PSCRT ='1'
      And A.PSDCR >= $(zconvDate)      
      Order By A.PSPLN;