LOG2
The LOG2 function returns the base two logarithm of a numeric value.
LOG2 Syntax
Use the following syntax when incorporating the LOG2 function in queries:
LOG2(expression)
Where expression evaluates to a numeric value.
LOG2 Examples
The example queries in this section run against the AnzoGraph sample Tickit data set, which captures sales activity for a fictional Tickit website where people buy and sell tickets for sporting events, shows, and concerts. You can load and explore this data set. For more information, see Working with the Tickit Data.
The example below determines the base two logarithm of the quantity of tickets sold for each ticket listing.
SELECT ?sale ?qtysold (LOG2(?qtysold) AS ?qtylog) FROM <tickit> WHERE { ?sale <qtysold> ?qtysold . } ORDER BY ?sale LIMIT 10
sale | qtysold | qtylog ------------+---------+---------- sales1 | 4 | 2.000000 sales10 | 1 | 0.000000 sales100 | 2 | 1.000000 sales1000 | 3 | 1.584962 sales10000 | 1 | 0.000000 sales100000 | 1 | 0.000000 sales100001 | 2 | 1.000000 sales100002 | 1 | 0.000000 sales100003 | 2 | 1.000000 sales100004 | 2 | 1.000000 10 rows