Select count(*)... mysql -
i have table 1 :
id : name : point 1 john 30 2 james 30 3 owen 20 4 mikel 20 5 jenny 20 6 kobi 10
how can use count() function select * have point 20 , less 20 , > 20
select (*) table_name point 20 // return 3 select (*) table_name point < 20 // return 1 select (*) table_name point > 20 // return 2
how can 3 query in 1 return table
count(*) ________ 3 1 2
use conditional aggregation:
select sum(point = 20), sum(point < 20), sum(point > 20) table_name;
also, don't use like
numbers! converts values strings. produce unexpected results , might make query unable use indexes.
Comments
Post a Comment