SQL基础教程(第2版)第6章 函数、谓词、CASE表达式:练习题


 

SELECT SUM(CASE WHEN sale_price <= 1000 THEN 1 ELSE 0 END)               AS low_price,
       SUM(CASE WHEN sale_price BETWEEN 1001 AND 3000 THEN 1 ELSE 0 END) AS mid_price,
       SUM(CASE WHEN sale_price >= 3001 THEN 1 ELSE 0 END)               AS high_price
 FROM Product;
View Code 6_2.sql

 

posted @ 2020-01-25 14:06  Marlon康  阅读(223)  评论(0编辑  收藏  举报