Result Handling
VQL follows specific logic for how results are ordered and how empty or missing data is evaluated.
Sorting & Ordering Results
Section link for Sorting & Ordering ResultsQuery results are returned in a default order. To enforce a specific order, use the ORDER BY clause.
- The API supports primary and secondary sorting of fields in ascending/descending order. Learn more about Order By.
- The API also supports sorting results by relevance to a
FINDoperator search phrase using theORDER BY RANKoperator. Learn more about Order By rank.
VQL does not support sorting multi-value picklist fields on raw objects.
VQL uses the following strategy when sorting null values:
- When ordering
documentsand standard volume Vault objects,nullvalues are last in the set of results in both ascending (ASC) and descending order (DESC). - When ordering raw objects and other query targets such as
groups,nullvalues are first in the set of results in ascending order (ASC) and last in descending order (DESC).
Null Field Values
Section link for Null Field ValuesUse null to find documents and objects with or without a value set on a particular field. For example, the following query returns all documents where the External ID field has no value but the Country field does have a value:
SELECT id, name__v
FROM documents
WHERE external_id__v = null AND country__v != nullVault considers fields with null values in inequalities. For example, the following query returns all documents where the country__v field is either null or a value not equal to 'Canada’:
SELECT id, name__v
FROM documents
WHERE country__v != 'Canada'