netezzamicrostrategy

ApplySimple Formula for last year in Microstrategy Netezza syntax


I'd like some help to convert the following applysimple statement to it's netezza equivalent.

ApplySimple("(
   select top 1 tradyrcode
   from tradingyear
   where tradyrcode < (
      select max(tradyrcode)
      from yrdays yd, control c
      where c.systemdate = yd.datecode
   )
   order by 1 desc
)",0)

I think I need to change the top 1 to limit 1 for it to work in netezza.

Any help would be much appreciated!


Solution

  • Where ‘top nn’ is at the beginning of the statement, ‘limit nn’ has to be at the very end, after a possible ‘order by’:

    select tradyrcode
    from trading-year
    where tradyrcode < (
      select max(tradyrcode)
      from yrdays yd, control c
      where c.systemdate = yd.datecode
    )
    order by 1 desc
    limit 1