開始使用免費開始

查詢 snowflake 綱要

想像你還沒有設定資料倉儲。相反地,你必須在公司的作業型資料庫上執行這個查詢,也就是說,你需要依照下列 snowflake 綱要重寫前一個查詢:

這個綱要中的資料表都已經載入。記住,我們的目標是找出各州從小說(novel)類型所賺得的金額總和。

本練習屬於課程

資料庫設計

檢視課程

練習說明

  • 從合適的資料表選取 state,以及總和 sales_amount
  • 完成兩個 JOIN 來取得 genre_id
  • 完成三個 JOIN 來取得 state_id
  • 加上條件,只選取 genrenovel 的書。
  • 以州別分組結果。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

-- Output each state and their total sales_amount
SELECT ___.___, ___(___)
FROM ___
    -- Joins for genre
    JOIN dim_book_sf on ___.___ = ___.___
    JOIN dim_genre_sf on ___.___ = ___.___
    -- Joins for state 
    JOIN ___ on ___.store_id = ___.store_id 
    JOIN ___ on ___.city_id = ___.city_id
	JOIN ___ on  ___.state_id = ___.state_id
-- Get all books with in the novel genre and group the results by state
WHERE  
    ___.___ = '___'
GROUP BY
    ___.___;
編輯並執行程式碼