Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql group by range

select 
  case 
    when RESULT between 0 and 50 then '0-50'
    when RESULT between 50 and 100 then '51-100'
    when RESULT between 100 and 150 then '101-150'
    when RESULT between 150 and 200 then '151-200'
    when RESULT between 200 and 250 then '201-250'
    else 'OTHERS'
  end as `Range`,
  count(1) as `Count`
from PERSON
group by `Range`;
Comment

MySQL GROUP BY

SELECT 
    c1, c2,..., cn, aggregate_function(ci)
FROM
    table
WHERE
    where_conditions
GROUP BY c1 , c2,...,cn;
Comment

MySQL GROUP BY

SELECT Manufacturer, COUNT(*) AS ModelsCount
FROM Products
WHERE Price > 30000
GROUP BY Manufacturer
ORDER BY ModelsCount DESC
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql failed to login as root@localhost 
Sql :: python postgresQL select table 
Sql :: split string from comma in sql 
Sql :: sql server change schema of a table 
Sql :: how to retrive the today date sql 
Sql :: sql any 
Sql :: foreign key constraint in ms sql 
Sql :: mysql update with join 
Sql :: current timestamp in milliseconds mysql 
Sql :: mysql update from select on same table 
Sql :: install mysql on ubuntu 
Sql :: oracle apex charging debug 
Sql :: get records in sql according to month name and count 
Sql :: sql declare variable 
Sql :: Check database restore status sql script 
Sql :: get time component of datetime sql 
Sql :: SQL Server Configuration Manager location 
Sql :: sql update insert and delete 
Sql :: postgresql not case sensitive where in 
Sql :: postgre alter table foreign key 
Sql :: show query code after create table in sql 
Sql :: alter table myisam to innodb 
Sql :: osx stop mysql service 
Sql :: grant all privileges microsoft sql 
Sql :: create tablespace oracle multiple datafiles 
Sql :: sql server drop database 
Sql :: dba_dependencies 
Sql :: view table mysql 
Sql :: mysql order by date asc null last 
Sql :: using minus query in SQL 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =