2 Replies Latest reply on Dec 5, 2013 5:24 AM by oliver.grist

    Division returns 0 in query

    oliver.grist

      Using SWQL Studio I have written a query where I want to do division in the SELECT to give me a percentage, however instead it seems to always return 0.

       

      The result of the query below from our test platform is:

      wouldtrigger | total | add | percentage

      15 | 151 | 166 | 0

       

      I am confused as the + operation works as expected, it is just / that fails. This confirms the numbers are ok and can be used in arithmetic.

       

      I am using SQWL Studio v3 with the installation: NPM 10.6

       

      My query is:

      SELECT wouldtrigger, total, (ABS(wouldtrigger)+ABS(total)) as add, (ABS(wouldtrigger)/ABS(total)) as percentage

      FROM

      (

          SELECT COUNT(DISTINCT N.NodeId) as wouldtrigger, (

              SELECT COUNT(DISTINCT N.NodeId) as total

              FROM Orion.Nodes N

              WHERE 

              (

                (Status = '1') AND

                (

                 (Vendor = 'Windows') OR

                 (Vendor = 'net-snmp')

                )

              )

          ) as total

          FROM Orion.Nodes N

          WHERE 

          (

            (Status = '1') AND

            (

             (Vendor = 'Windows') OR

             (Vendor = 'net-snmp')) AND

            (PercentMemoryUsed > 90)

          )

      )