SAP® Business Data Cloudからデータを探索する

このトピックでは、Snowflakeと共有されているデータを探索します。すべての例は、Snowflakeを使用したデータへのアクセスを紹介することを目的としています。

次のセクションでは、データベースの例として CUSTOMER を使用しますが、同じステップを使用してデータベース内のデータを探索できます。

データベース、スキーマ、テーブルを探索する

データベースを調べます。

DESC DATABASE CUSTOMER;
Copy

これにより、次のような結果が生成されます。

+--------------------------------+---------------------------------+
|created_on                              | name                            | kind      |
+--------------------------------+---------------------------------+
| 2025-12-17 13:30:01.062 -0800  | INFORMATION_SCHEMA      | SCHEMA    |
| 2025-12-17 13:11:12.206 -0800  | customer            | SCHEMA    |
+--------------------------------+---------------------------------+

各行がデータベースのスキーマを表します。

データベースのテーブルを調べます。

SHOW TABLES IN CUSTOMER;
Copy

これにより、次のような結果が生成されます。

+------------------------+----------------+-------------+-------+-------+--------+
| name                               | database_name  | schema_name | kind  | rows  | bytes  |
+------------------------+----------------+-------------+-------+-------+--------+
| customer                           | CUSTOMER       | customer    | TABLE | 2174  | 215708 |
| customercompanycode          | CUSTOMER               | customer    | TABLE | 1792  | 37311  |
| customerdunning                | CUSTOMER             | customer    | TABLE | 44    | 4912   |
| customersalesarea            | CUSTOMER               | customer    | TABLE | 442   | 34415  |
| customersalesareatax   | CUSTOMER             | customer    | TABLE | 883   | 9153   |
| customerunloadingpoint | CUSTOMER             | customer    | TABLE | 37    | 13253  |
+------------------------+----------------+-------------+-------+-------+--------+

CUSTOMER データベースのクエリテーブル

「顧客」テーブルをクエリします。

SELECT * FROM CUSTOMER.customer.customer;

SELECT * FROM CUSTOMER.customer.customer WHERE CREATEDBYUSER = 'KAPOORM'
Copy

共有データから派生データを作成する

2つの共有データ製品からテーブルを結合して、L1データを作成します。

-- Join tables in CUSTOMER and ENTRYVIEWJOURNALENTRY to find top 10 customers by revenue
SELECT
    c.customer,
    c.customername,
    c.country,
    c.region,
    c.businesstype,
    COUNT(DISTINCT e.accountingdocument) as num_transactions,
    SUM(e.amountincompanycodecurrency) as total_revenue,
    AVG(e.amountincompanycodecurrency) as avg_transaction_amount
FROM CUSTOMER.customer.customer c
JOIN ENTRYVIEWJOURNALENTRY.entryviewjournalentry.operationalacctgdocitem e
   ON c.customer = e.customer
WHERE c.deletionindicator = FALSE
GROUP BY 1,2,3,4,5
ORDER BY total_revenue DESC
LIMIT 10;
Copy

新しいデータベースで選択としてテーブル( CTAS )を作成します

CTAS を保持する新しいデータベースを作成します。

CREATE DATABASE CUSTOMER_CTAS_DEMO;
USE DATABASE CUSTOMER_CTAS_DEMO;

-- Create the CTAS
CREATE OR REPLACE TABLE top_customers_by_revenue AS
SELECT
  c.customer,
  c.customername,
  c.country,
  c.region,
  c.businesstype,
  COUNT(DISTINCT e.accountingdocument) as num_transactions,
  SUM(e.amountincompanycodecurrency) as total_revenue,
  AVG(e.amountincompanycodecurrency) as avg_transaction_amount
FROM CUSTOMER.customer.customer c
JOIN ENTRYVIEWJOURNALENTRY.entryviewjournalentry.operationalacctgdocitem e
    ON c.customer = e.customer
WHERE c.deletionindicator = FALSE
 GROUP BY 1,2,3,4,5
 ORDER BY total_revenue DESC;

 -- Query the CTAS
 SELECT * FROM top_customers_by_revenue LIMIT 10;
Copy