mysql查询

1、分组查询

SELECT houTransactionTime, count(houTransactionTime) 
    FROM secondary.house2 
        where regionOne = "高新"
        group by houTransactionTime;

 2、分组区间

根据 hou.deal_price 分成区间 0, 60, 80, 100,150,200,300

# 区间分组
select elt(interval(hou.deal_price, 0, 60, 80, 100,150,200,300), '1/0-60', '2/60-80', '3/80-100', '4/100-150','5/150-200','6/200-300','7/300-more') as deal_price_level, avg(hou.care_peos) as care_num
    from secondary.housedetails  as hou
    where not hou.care_peos = 0
    group by elt(interval(hou.deal_price, 0, 60, 80, 100,150,200,300), '1/0-60', '2/60-80', '3/80-100', '4/100-150','5/150-200','6/200-300','7/300-more');

 

posted @ 2021-04-08 16:24  天宇爱水  阅读(33)  评论(0编辑  收藏  举报