6 Replies Latest reply: Oct 28, 2014 4:24 AM by espen skeie RSS

    Converting a SQL code to something useful in Qlikview script

    espen skeie

      Hi

       

      I have a code that pull data from SQL, and I need to convert it to something that will work in qlikview script. Here is the SQL code:

       

      M18 as
      (
      select distinct log_opportunityid,
      createdon = max(createdon),
      month = dateadd(m,datediff(m,0,dateadd(m,-18,getdate())),0)
      from [dbo].[Filteredlog_salesstagetracking] as t1
      where createdon < dateadd(m,datediff(m,0,dateadd(m,-17,getdate())),0)
      group by log_opportunityid
      ),
      
      

       

      And this is what I have managed so far, but there's some stuff missing, like the mac(t1.createdon) stuff.....

       

      M18:
      LOAD
        log_opportunityid,
      // Max(createdon) as createdon,   //Error when this code is active...
        Num(MonthStart(addmonths(today(),-18))) as Month
      FROM [..............Filteredlog.qvd] (qvd)
      Where createdon < MonthStart(Addmonths(today(),-17));
      
      

       

       

      Kind regards

      Espen