---
schema_version: "1"
id: a6ea68344d9a29a3e152e438d31f100da38831accd79cbc6be51b91698122ef7
title: analytics query
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi-dev-guide-cli-reference/guides/cli/sf/bi-cli-reference-analytics-query-unified.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-cli-reference/guide/bi-cli-reference-analytics-query-unified.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 59f54075a4d1179ca1f4f520465ae50365701c7b4c9a1640b34ba5ff62666b6c
products:
  - Salesforce Analytics Plugin CLI Command Reference
  - analytics
---

# analytics query

Execute an Analytics query.

## Examples for analytics query

```nolang
sf analytics query -f query.saql
```

```nolang
sf analytics query -f query.sql -t America/Denver
```

```nolang
sf analytics query -q "..." --sql --limit 10 -r csv
```

## Command Syntax

- `sf analytics query`

    - : [`--json`]

      [`--apiversion` APIVERSION]

      `-o` TARGETORG

      [`-f` QUERYFILE]

      [`-q` QUERY]

      [`--nomapnames`]

      [`--sql`]

      [`-t` TIMEZONE]

      [`--connector` CONNECTOR]

      [`--limit` LIMIT]

      [`-r` RESULTFORMAT]

## Parameters

- `--json`

    - : Optional

      Format output as JSON.

      Type: boolean

- `--api-version` APIVERSION

    - : Optional

      Override the API version used for API requests made by this command.

      Type: string

- `-o` TARGETORG

    - : Required

      Username or alias of the target org. Not required if the target-org configuration variable is set.

      Type: string

- `-f` | `--queryfile` QUERYFILE

    - : Optional

      Path to the file containing the query to execute.

      Type: filepath

- `-q` | `--query` QUERY

    - : Optional

      The query to execute.

      Type: string

- `--nomapnames`

    - : Optional

      Skip mapping dataset names in the SAQL query to ids.

      Type: boolean

- `--sql`

    - : Optional

      Execute the query as SQL.

      Type: boolean

- `-t` | `--timezone` TIMEZONE

    - : Optional

      The timezone for the query.

      Type: string

- `--connector` CONNECTOR

    - : Optional

      Execute the SQL query against this external data connector id or name.

      Type: string

- `--limit` LIMIT

    - : Optional

      The maximum number of rows to include.

      Type: number

- `-r` | `--resultformat` RESULTFORMAT

    - : Optional

      Result format emitted to stdout.

      Type: enum

      Permissible values are: human, csv, json

      Default value: human

