2 Replies Latest reply: Jul 18, 2011 7:44 AM by Patrick Laredo RSS

    Sum(If()) in Script

      Hi,

           I have the following expression in the scripting editor

         

       

       

           Load Rig,

           'Plans' as P,

           Sum(If(Planname<>'',1,0))

          

           Resident v

           Group by Rig

          

           While Loading the Script I am getting an Error 'Error in Expression'.

       

            I have some table as v.

       

            Please correct me as to where am I going wrong?

       

        Regards

      Navin Gorapalli

        • Sum(If()) in Script

          Navin,

           

          Your script should be

           

          Load Rig,

               'Plans' as P,

               Sum(If(Planname<>'',1,0)) as Col

               Resident v

               Group by Rig, Plans

           

          Regards

          Ravi Kumar

          • Sum(If()) in Script
            Patrick Laredo

            hi,

             

            you want a table with the number of Plans per Rig? and in your table v you have a filed called PlanName and if PlanName is filled in (that is different to null) ypu want to count each record as being a plan. Is this correct?

             

            then try this

             

            load Rig,

            'Plans' as P,

            count(Planname)

            resident v

            where len(Planname)>0

            group by Rig;

             

            hope this helps.