5 Replies Latest reply: Jun 20, 2011 11:53 AM by Chris Draper RSS

    Using conditions in the script to create groups

    Chris Draper

      I'm trying to create a new field within the script so that I can group data within Qlikview.

       

      The condition is based on the 1st letter of the field 'Product Class' e.g. All product classes equal to 'A' = 'Group A' and everything else = 'Other'

       

      Here is what I have so far:

       

      ODBC CONNECT TO SysproCompanyA;

      SQL SELECT Area,

      CostValue,

      Customer,

      CustomerClass,

      NetSalesValue,

      ProductClass,

      QtyInvoiced,

      Salesperson,

      StockCode,

      TrnMonth,

      TrnYear,

      FROM SysproCompanyA.dbo.ArTrnDetail;

       

      SELECT ProductClass, (Left(ProductClass,1)) AS Sector FROM SysproCompanyA.dbo.ArTrnDetail;

       

      I've tried various If statments but I can't get any to work. Can you help?

       

      BTW this is my 1st day of looking at any SQL scripting, so go easy.