在本文中,您將瞭解如何使用範例 KQL 查詢來初步查看您的資料。
查詢是一種處理資料和傳回結果的唯讀要求。 該要求是採用易於理解、撰寫及自動執行的資料流程模型,並採用純文字加以陳述。 查詢一律會在特定資料表或資料庫的內容中執行。 查詢至少包含源資料參考,以及依序套用的一或多個查詢運算子,透過使用管道字元 (|) 來分隔運算子,以可視化方式表示。
如需 Kusto 查詢語言的詳細資訊,請參閱 Kusto 查詢語言 (KQL) 概觀。
必要條件
使用程式碼查詢
您可以透過兩種方式啟動功能表來查詢 KQL 資料表。
選取左窗格中的表格。 在下列範例中,已選取 yelllowtaxidata 。
選取頂端功能表上的 [使用程式碼查詢]。
另一種方法是將鼠標懸停在表格上,選擇 ......(省略號),您會看到下列內容功能表,其中包含相同的 [使用程式碼的查詢] 選項。
選取您要執行的 KQL 查詢 。 若要執行範例 SQL 查詢,請選取 [SQL],然後選取您要執行的 SQL 查詢。 查詢會自動執行並顯示結果,如下圖所示。
範例查詢
顯示任意 100 筆記錄
// Use 'take' to view a sample number of records in the table and check the data.
yellowtaxidata
| take 100
過去 24 小時內擷取的記錄
// See the most recent data - records ingested in the last 24 hours.
yellowtaxidata
| where ingestion_time() between (now(-1d) .. now())
取得資料表結構描述
// View a representation of the schema as a table with column names, column type, and data type.
yellowtaxidata
| getschema
取得上次擷取時間
// Check when the last record in the table was ingested.
yellowtaxidata
| summarize LastIngestionTime = max(ingestion_time())
顯示記錄總數
//See how many records are in the table.
yellowtaxidata
| count
摘要每小時擷取次數
// This query returns the number of ingestions per hour in the given table.
yellowtaxidata
| summarize IngestionCount = count() by bin(ingestion_time(), 1h)
SQL:顯示任意 100 筆記錄
-- View a sample of 100 records in the table.
select top 100 * from yellowtaxidata
SQL:顯示記錄總數
-- See how many records are in the table.
select count_big(*) from yellowtaxidata
[總管] 窗格的螢幕擷取畫面,其中顯示資料表的 [更多] 功能表。[查詢資料表] 選項會反白顯示。
[探索資料] 視窗的螢幕擷取畫面,其中顯示即時智慧中範例查詢的查詢結果。