Skip to main content

Run your first query

In this tutorial you write a query on the sample sales data, run it, and read the result. It takes about five minutes and only reads data.

Prerequisites​

  • You can log in to the Lakehouse Portal. See Lakehouse Quick Start.
  • Your role lets you run queries. Your Admin assigns roles in Access management.
  • You have access to the tpcds catalog. Every Lakehouse includes it, but your Admin must grant you access in Data Security first.

What you'll build​

By the end you will have a query that counts sales per store, a result grid with the answer, and a second result from a quick check query.

Open Query Editor​

  1. Log in to the Lakehouse Portal.
  2. Select Query Editor in the navigation menu.

A new tab opens with the placeholder Write SQL to query ... in the editor.

Query Editor with a new empty tab

Set the default catalog and schema​

  1. Select tpcds in the catalog list on the toolbar.
  2. Select sf1 in the schema list.

You can now write only the table name, without the catalog and schema in front of it.

Write the query with auto-complete​

  1. Type SEL in the editor.
  2. Press Tab to accept the suggestion SELECT.
  3. Complete the query as follows. After you type FROM, pick store_sales from the suggestion list.
SELECT ss_store_sk, COUNT(*) AS sales_count
FROM store_sales
GROUP BY ss_store_sk
ORDER BY sales_count DESC;

Auto-complete only suggests tables and columns you have access to.

Run the query​

  1. Click anywhere inside the query.
  2. Select Execute, or press Ctrl+Enter.

The result panel shows Running query with a progress bar and a run timer. When the query finishes, the Result 1 tab shows the rows, for example 12 rows | 1.84s.

Result 1 tab with the number of sales per store

Run two statements at once​

  1. Add this line under the first query.

    SELECT COUNT(*) FROM store_sales;
  2. Select both queries with your mouse.

  3. Select Execute.

The result panel now shows Result 1 and Result 2, one tab for each statement.

Summary​

You set a default catalog and schema, wrote a query with auto-complete, ran a single statement, and ran two statements in one go.

Next steps​