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
举例如下图:
sql:查询不同区间数量_第1张图片

你可能感兴趣的:(数据库MySQL)