Learn R Programming

Causata (version 4.2-0)

Where: Query WHERE clause and comparison operations

Description

The Where function creates a WHERE clause that can be added to Query or FocalPointQuery objects.

Usage

Where(variable, operation=NULL)

Arguments

variable
A string matching the name of a Causata variable, or a string representing a SQL WHERE clause, like "variable <> 123".
operation
An operator of class RawOperator, such as GreaterThan(123) or EqualTo(123)

Value

An object of class Where used for building queries.

Details

There are three basic usage patterns. These are all equivalent:
  • Where("variable.`variable-name` <> 'string value'")
  • Where("variable-name", "<> 'string value'")
  • Where("variable-name", NotEqualTo("string value")

The first form is a raw SQL WHERE clause, when using this form, you must correctly reference and escape the variable name, and the value for the operator you choose. The second form is (variable.name, operation). Using this form the variable name will be correctly referenced and escaped. However, the right hand side (the operation) must still be correctly escaped by you. The third form is (variable.name, operation.object). Using this form the variable name and operation are both correctly escaped. The allowable operations in the third form are as follows:

Operation
Arguments
BeginningWith
Single value
EqualTo
Single value
NotEqualTo
Single value
GreaterThan
Single value
GreaterThanOrEqualTo
Single value
LessThan
Single value
LessThanOrEqualTo
Single value
Like
Single value
In
One or more comma-separated values

See Also

Query, FocalPointQuery.

Examples

Run this code
q <- FocalPointQuery("page-view") + Where("page-view-count", GreaterThan(10))
q <- FocalPointQuery("page-view") + 
     Where("total-spend", LessThanOrEqualTo(100)) + 
     Where("total-spend", GreaterThan(1))

Run the code above in your browser using DataLab