#8 Microsoft Fabric: Create SQL Query and view

We can manage our warehouse within our workspace by using SQL endpoint. In this test, we will write a SQL statement that calculates the total sales amount by month. We’ll then save this statement as a view in our SQL endpoint (Warehouse). This will allow us to easily access the total sales amount by month in the future.

1. Under your workspace, navigate to SQL endpoint TestLH

No alt text provided for this image

2. On the Home tab, select New SQL query.

No alt text provided for this image

3. In the query editor, copy and paste or type the SQL query below to calculate the total sales amount by month number in descending order. Once entered, select Run to view results.

SELECT
MONTH(DateKey) AS "MonthNumber",
SUM(SalesAmount) AS "TotalSalesAmount" 
FROM FactOnlineSales
GROUP BY MONTH(DateKey) 
No alt text provided for this image

4. Double click in “SQL query 1” to rename it as “TotalSalesAmount”

No alt text provided for this image

5. Highlight the full query text and select Save as view.

No alt text provided for this image

6. In the Save as view window, set the View name to TotalSalesByMonth and then select OK.

No alt text provided for this image

7. In the Explorer, expand the Views section and select TotalSalesByMonth to view the results in the Data preview.

No alt text provided for this image

8. Now, you can continue to write your SQL queries and explore the SQL endpoint editor.

Call Now