This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Division returns 0 in query

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)

    )

)