> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/numeric/bit_shift_right",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for BIT_SHIFT_RIGHT

# BIT_SHIFT_RIGHT

export const QueryWindow = ({content}) => {
  const {sql, result} = content;
  const [inited, setInited] = useState(false);
  const buttonRef = useRef(null);
  useEffect(() => {
    if (!inited && buttonRef.current) {
      runQuery(buttonRef.current, true);
      setInited(true);
    }
  }, []);
  return <div className="query-window">
      <div className="query-toolbar">
        <button className="run-button" onClick={ev => runQuery(ev.target)} ref={buttonRef}>Run Query</button>
        <span className="window-title">Interactive SQL Playground 🔥</span>
      </div>
      <div className="query-content">
        <pre><code className="firebolt-sql language-sql" contentEditable="true" spellCheck="false" data-original-query={sql}>{sql}</code></pre>
        <script type="application/json" className="fallback-result" style={{
    display: "none"
  }}>{JSON.stringify(result)}</script>
        <div className="server-unavailable-banner query-window-hidden">
          The Firebolt playground server is currently unavailable. Using precomputed query results.
        </div>
        <div className="query-results"></div>
      </div>
    </div>;
};

Shifts the bits in the first argument to the right by `n` bits, where `n` is the second argument. Shifting right by `n` positions is equivalent to dividing the number by `2^n`.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
BIT_SHIFT_RIGHT(<value>, <bits>)
```

## Parameters

| Parameter | Description                   | Supported input types |
| :-------- | :---------------------------- | :-------------------- |
| `<value>` | Specifies the value to shift. | `INT`, `BIGINT`       |
| `<bits>`  | The number of bits to shift.  | `INT`                 |

## Return Types

The `BIT_SHIFT_RIGHT` function returns a result of either type `INT` or `BIGINT`, depending on the type of the input `<expression>`.

## Examples

**Example**

The following code example shifts `0001`, the binary representation of `1`, to the right by two bits, which yields `0000`, the binary representation for `0`:

<QueryWindow
  content={{
"sql": "SELECT bit_shift_right(1, 2) AS res;",
"result": {
"data": [
  [
    0
  ]
],
"meta": [
  {
    "name": "res",
    "type": "int"
  }
],
"query": {
  "query_id": "61fc3ce5-464e-4258-aaf9-6d00487d6839",
  "query_label": null,
  "request_id": "d41fc4b1-14f4-4f35-83db-d06a063001a3"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006857,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000268297,
  "time_to_execute": 9.7277e-05
}
}
}}
/>

**Example**

The following code example shifts `00101`, the binary representation of `5`, to the right by two bits, which yields `00001`, the binary representation for `1`:

<QueryWindow
  content={{
"sql": "SELECT bit_shift_right(5, 2) AS res;",
"result": {
"data": [
  [
    1
  ]
],
"meta": [
  {
    "name": "res",
    "type": "int"
  }
],
"query": {
  "query_id": "8830b12e-61b7-45e1-86d3-a4139235785e",
  "query_label": null,
  "request_id": "89212b42-e3e0-4a86-b2ff-68d30c76acfd"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.008856,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000241212,
  "time_to_execute": 8.3806e-05
}
}
}}
/>

**Example**

The following code example shifts the binary representation of `-3`, which is `1111111111111101` in signed two's complement, one bit to the right, resulting in `1111111111111110`, the signed two's complement of `-2`:

<QueryWindow
  content={{
"sql": "SELECT bit_shift_right(-3, 1) AS res;",
"result": {
"data": [
  [
    -2
  ]
],
"meta": [
  {
    "name": "res",
    "type": "int"
  }
],
"query": {
  "query_id": "281fcd28-bc0d-431d-b0b3-a105dec8e80f",
  "query_label": null,
  "request_id": "21c8d6f4-2b57-4088-b746-de5e0b35f11c"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006238,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000256069,
  "time_to_execute": 8.7102e-05
}
}
}}
/>
