開始使用免費開始

修剪字串 I

雜亂的字串會造成問題,因為在未清理前往往不容易分析。

在分析 airports 資料表時,你發現 airport_name 欄位的部分值相當雜亂,這些字串在前後夾帶了空白。

TRIM() 函式可以幫你移除 airports 資料表中這些多餘的空白。

本練習屬於課程

在 SQL Server 資料庫中清理資料

檢視課程

練習說明

  • 檢視 airports 資料表的內容,看看有哪些前後空白。
  • 使用合適的函式移除前後空白。
  • 選取資料所在的來源資料表。

動手互動練習

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

SELECT 
	airport_code,
	-- Use the appropriate function to remove the extra spaces
    ___(___) AS airport_name,
	airport_city,
    airport_state
-- Select the source table
FROM ___
編輯並執行程式碼