统计sql

 

按月统计

select c.mon,count (c.mon) as total from (select  TO_CHAR(t.create_time,'MM') as mon

from order_form t

where t.nwoffice_id=176

) c group by c.mon order by c.mon

分组统计

SELECT
CASE WHEN t.price <= 50 THEN '50元以下'
WHEN t.price > 50 AND t.price <= 100  THEN '50-100元'
WHEN t.price > 100   THEN '100元以上'

END salary_class,
COUNT(*) as count
FROM    order_form t where t.nwoffice_id=176
GROUP BY
CASE WHEN t.price <= 50 THEN '50元以下'
WHEN t.price > 50 AND t.price <= 100  THEN '50-100元'
WHEN t.price > 100   THEN '100元以上'
END;

你可能感兴趣的:(sql,c,Class)