--- title: SQL expressions reference for dimensions slug: n1cd0393 canonical_url: https://docs.coveo.com/en/n1cd0393/ collection: coveo-analytics source_format: adoc --- # SQL expressions reference for dimensions This article is a reference of SQL expressions relating to [Coveo Analytics dimensions](https://docs.coveo.com/en/258/) that can be added to [queries](https://docs.coveo.com/en/231/) which can be run against [Coveo Analytics data](https://docs.coveo.com/en/259/) to build [reports](https://docs.coveo.com/en/266/). The query syntax is Snowflake-specific and can be used in the [Snowflake reader account](https://docs.coveo.com/en/l9e90297/) or [Snowflake data share](https://docs.coveo.com/en/m1rf0146/). > **Note** > > SQL expressions must be entered within a `SELECT` statement. > For example: > > ```sql SELECT "origin_country" AS "Search Country", COUNT(distinct "search_id") AS "Search Event Count" FROM "COVEO"."ua"."searches_shared" WHERE CONVERT_TIMEZONE('UTC', 'America/New_York', "datetime") BETWEEN '2022-12-13 00:00:00.000' :: TIMESTAMP_TZ AND '2023-01-12 23:59:59.999' :: TIMESTAMP_TZ GROUP BY "Search Country" ORDER BY "Search Event Count" DESC ``` ## Client ID ```sql COALESCE( "searches_shared"."client_id", "searches_shared"."visitor_id" ) COALESCE( "clicks_shared"."client_id", "clicks_shared"."visitor_id" ) COALESCE( "custom_events_shared"."client_id", "custom_events_shared"."visitor_id" ) COALESCE( "all_events_shared"."client_id", "all_events_shared"."visitor_id" ) ``` ## Visitor ID ```sql COALESCE( "searches_shared"."client_id", "searches_shared"."visitor_id" ) COALESCE( "clicks_shared"."client_id", "clicks_shared"."visitor_id" ) COALESCE( "custom_events_shared"."client_id", "custom_events_shared"."visitor_id" ) COALESCE( "all_events_shared"."client_id", "all_events_shared"."visitor_id" ) ``` ## Has Results ```sql "searches_shared"."with_results" "all_events_shared"."with_results" ``` ## User Name ```sql "searches_shared"."user_name" "clicks_shared"."user_name" "custom_events_shared"."user_name" "all_events_shared"."user_name" ``` ## User ID ```sql "searches_shared"."unique_user_id" "clicks_shared"."unique_user_id" "custom_events_shared"."unique_user_id" "all_events_shared"."unique_user_id" ``` ## Is Anonymous ```sql "searches_shared"."is_anonymous" "clicks_shared"."is_anonymous" "custom_events_shared"."is_anonymous" "all_events_shared"."is_anonymous" ``` ## Visit ```sql "searches_shared"."visit_id" "clicks_shared"."visit_id" "custom_events_shared"."visit_id" "all_events_shared"."visit_id" ``` ## Month ```sql DATE_TRUNC( 'month', CONVERT_TIMEZONE('UTC', , "searches_shared"."datetime") ) DATE_TRUNC( 'month', CONVERT_TIMEZONE('UTC', , "clicks_shared"."datetime") ) DATE_TRUNC( 'month', CONVERT_TIMEZONE( 'UTC', , "custom_events_shared"."datetime" ) ) DATE_TRUNC( 'month', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) DATE_TRUNC( 'month', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) ``` ## Week ```sql DATE_TRUNC( 'week', CONVERT_TIMEZONE('UTC', , "searches_shared"."datetime") ) DATE_TRUNC( 'week', CONVERT_TIMEZONE('UTC', , "clicks_shared"."datetime") ) DATE_TRUNC( 'week', CONVERT_TIMEZONE( 'UTC', , "custom_events_shared"."datetime" ) ) DATE_TRUNC( 'week', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) DATE_TRUNC( 'week', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) ``` ## Day ``` DATE_TRUNC( 'day', CONVERT_TIMEZONE('UTC', , "searches_shared"."datetime") ) DATE_TRUNC( 'day', CONVERT_TIMEZONE('UTC', , "clicks_shared"."datetime") ) DATE_TRUNC( 'day', CONVERT_TIMEZONE( 'UTC', , "custom_events_shared"."datetime" ) ) DATE_TRUNC( 'day', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) DATE_TRUNC( 'day', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) ``` ## Hour ```sql DATE_TRUNC( 'hour', CONVERT_TIMEZONE('UTC', , "searches_shared"."datetime") ) DATE_TRUNC( 'hour', CONVERT_TIMEZONE('UTC', , "clicks_shared"."datetime") ) DATE_TRUNC( 'hour', CONVERT_TIMEZONE( 'UTC', , "custom_events_shared"."datetime" ) ) DATE_TRUNC( 'hour', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) DATE_TRUNC( 'hour', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) ``` ## Minute ```sql DATE_TRUNC( 'minute', CONVERT_TIMEZONE('UTC', , "searches_shared"."datetime") ) DATE_TRUNC( 'minute', CONVERT_TIMEZONE('UTC', , "clicks_shared"."datetime") ) DATE_TRUNC( 'minute', CONVERT_TIMEZONE( 'UTC', , "custom_events_shared"."datetime" ) ) DATE_TRUNC( 'minute', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) DATE_TRUNC( 'minute', CONVERT_TIMEZONE( 'UTC', , "all_events_shared"."datetime" ) ) ``` ## Search ID ```sql "searches_shared"."search_id" ``` ## Device ```sql "searches_shared"."origin_device" "clicks_shared"."origin_device" "custom_events_shared"."origin_device" "all_events_shared"."origin_device" ``` ## Device Category ```sql "searches_shared"."device_category" "clicks_shared"."device_category" "custom_events_shared"."device_category" "all_events_shared"."device_category" ``` ## Language ```sql "searches_shared"."origin_language" "clicks_shared"."origin_language" "custom_events_shared"."origin_language" "all_events_shared"."origin_language" ``` ## Country ```sql "searches_shared"."origin_country" "clicks_shared"."origin_country" "custom_events_shared"."origin_country" "all_events_shared"."origin_country" ``` ## City ```sql "searches_shared"."origin_city" "clicks_shared"."origin_city" "custom_events_shared"."origin_city" "all_events_shared"."origin_city" ``` ## Region ```sql "searches_shared"."origin_region" "clicks_shared"."origin_region" "custom_events_shared"."origin_region" "all_events_shared"."origin_region" ``` ## Is Mobile ```sql "searches_shared"."origin_is_mobile" "clicks_shared"."origin_is_mobile" "custom_events_shared"."origin_is_mobile" "all_events_shared"."origin_is_mobile" ``` ## Browser ```sql "searches_shared"."web_browser" "clicks_shared"."web_browser" "custom_events_shared"."web_browser" "all_events_shared"."web_browser" ``` ## Query Pipeline ```sql "searches_shared"."query_pipeline" "clicks_shared"."query_pipeline" "all_events_shared"."query_pipeline" ``` ## Event Cause ```sql "searches_shared"."cause2" "clicks_shared"."cause2" "all_events_shared"."cause2" ``` ## Group ```sql "group_name_shared"."groups" ``` ## Keyword ```sql "keywords_shared"."keyword" ```