# Dataset$query

### Dataset$<mark style="color:purple;">query</mark>(*query\_string*) → [Query](/api/client-libraries/redivis-r/reference/query.md)

Execute a SQL query scoped to a particular dataset. Table names do not need to be fully qualified, since all tables are assumed to be within the dataset.

### **Parameters:**

**`query_string` :&#x20;*****str*** \
The SQL query to execute. Must follow the [Redivis SQL query syntax](https://docs.redivis.com/reference/projects/transform-nodes/raw-sql).

### **Returns:**

[**Query**](/api/client-libraries/redivis-r/reference/query.md)

### Examples

```r
dataset <- redivis$organization("Demo")$dataset("CMS 2014 Medicare Data")

query = dataset$query("
    SELECT 
        hospice_providers.name, 
        inpatient_charges.drg_definition
    -- The tables inpatient_chargers, hospice_providers are assumed to be 
    -- within the scoped dataset
    FROM inpatient_charges
    INNER JOIN hospice_providers 
        ON hospice_providers.provider_id = inpatient_charges.provider_id
")

print(query$to_tibble())
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/api/client-libraries/redivis-r/reference/dataset/datasetusdquery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
