Skip to content

Instantly share code, notes, and snippets.

@imrexhuang
Created April 6, 2016 12:47
Show Gist options
  • Save imrexhuang/185a69803dc7c09ce9bdcc5221699f15 to your computer and use it in GitHub Desktop.
Save imrexhuang/185a69803dc7c09ce9bdcc5221699f15 to your computer and use it in GitHub Desktop.
--SQL Server 2012 T-SQL資料庫設計 (悅知文化)
--http://www.delightpress.com.tw/book.aspx?book_id=skud00022
--CH06 P.363
USE Northwind
SELECT ProductID,UnitPrice,
CASE
WHEN UnitPrice < 50 THEN '低於 50'
WHEN UnitPrice >= 50 AND UnitPrice<100 THEN '低於 100'
WHEN UnitPrice >= 100 AND UnitPrice<500 THEN '低於 500'
ELSE '高於 500'
END AS 價格類別
FROM Products
ORDER BY 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment