> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/deutsch/advanced-functions-and-tools/sql-access.md).

# SQL-Zugriff

<figure><img src="https://2396827744-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhNyN4taXWt0p7OGOOSfW%2Fuploads%2Fgit-blob-0282304b14050c894879e8e693bea68ab24ad617%2Fsql_direct_access_settings.png?alt=media" alt="Einstellungen für den direkten SQL-Zugriff"><figcaption></figcaption></figure>

## Überblick

Im Einstellungsmodul von DocBits können Administratoren per SQL direkt auf die BI-Datenbank zugreifen. Diese Funktion ist für fortgeschrittenes Datenmanagement und individuelle Berichtsanforderungen vorgesehen.

### Auf den direkten SQL-Zugriff zugreifen

Navigieren Sie im Einstellungsmodul zum Bereich „SQL Direct Access“. Dort finden Sie die Zugangsdaten und Zugriffsdetails, darunter Benutzername, Passwort, Datenbankname und Host-Informationen.

* **Benutzername:** user\_23f3d6
* **Passwort:** *Verschlüsselt*
* **Datenbank:** demo
* **Host:** siehe Screenshot

## **Beispiel für Zugriffsdetails:**

```sql
SELECT
    COUNT(*),
    status,
    invoice_type
FROM dashboard
GROUP BY
    status,
    invoice_type

```

#### Ergebnisse einer Beispielabfrage

Die folgenden Ergebnisse zeigen die Anzahl der Dokumente nach Status und Rechnungstyp:

* **Ready for Validation:** 71 Rechnungen, 6 nicht spezifiziert
* **Pending Confirmation:** 1 nicht spezifiziert
* **Finished:** 3 nicht spezifiziert, 1 Rechnung
* **Error:** 2 nicht spezifiziert

#### clickhouse-client für den Terminalzugriff verwenden

Entwickler, die lieber das Terminal verwenden, können den Zugriff über `clickhouse-client` herstellen:

```bash
clickhouse-client --host <hostname_or_ip> --port <port> --user <username> --password <your_password> --database <database_name>

```

### Beispielaggregation mit SELECT

Die folgende Abfrage aggregiert vorhandene Zeilen. Sie erstellt keine materialisierte Sicht. Ein Nur-Lese-Zugang gewährt nicht die dafür nötigen Schreibrechte. Passen Sie Tabellennamen und Konvertierungen an Schema, Zahlenformat und Währung an. Summieren Sie unterschiedliche Währungen nicht ohne ausdrückliche Umrechnung.

```sql
SELECT toStartOfWeek(created_on) as week_start, sum(toFloat64OrZero(field_value)) as total_sum
FROM document_extracted_data
WHERE field_name = 'total_amount'
GROUP BY week_start

```

Dieses Beispiel zeigt, wie Gesamtbeträge nach der Woche ihrer Erstellung gruppiert werden. Das ist hilfreich für wöchentliche Finanzübersichten oder Prüfpfade.

## Weitere Ressourcen

Für weitere Unterstützung oder erweiterte Konfigurationen wenden Sie sich bitte an unser Support-Team oder nutzen Sie unsere umfassenden Videoschulungen im Hilfebereich.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.docbits.com/deutsch/advanced-functions-and-tools/sql-access.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
