1. 程式人生 > >sql:查詢不同區間數量

sql:查詢不同區間數量

分割槽域查詢滿足條件的數量值:select t1.p1 as num1,t2.p2 as num2,t3.p3 as num3 from
(select count(BASICPRICE) as p1 from product where BASICPRICE>=40.0 and BASICPRICE <=440.0 ) t1 INNER JOIN
(select count(BASICPRICE) as p2 from product where BASICPRICE>=440.1 and BASICPRICE <=840.0 ) t2 INNER JOIN
(select count(BASICPRICE) as p3 from product where BASICPRICE>=840.1 and BASICPRICE <=1240.0 ) t3舉例如下圖: