mysql生成摘要:
使用count函数生成摘要---
select count(*) from driver_log;
select count(*) from states;
select table_rows
from information_schema.tables
where table_schema = 'cookbook'
and table_name = 'states';
show tables status;
select count(*) from driver_log where miles > 200;
select count(*) from driver_log where name = 'Suzi';
select count(*) from states where statehood < '1900-01-01';
select count(*) from states where statehood between '1800-01-01' and '1899-12-31';
select count(if(dayofweek(trav_date)=7, 1, null)) as 'Staturday trips',
count(if(dayofweek(trav_date)=1, 1, null)) as 'Sunday trips'
from driver_log;
select count(if(dayofweek(trav_date) in (1, 7), 1, null)) as 'weekend trips',
count(if(dayofweek(trav_date) in (1, 7), null, 1)) as 'weekday trips'
from driver_log;
create view trip_summary_view as
select count(if(dayofweek(trav_date) in (1, 7), 1, null)) as 'weekend trips',
count(if(dayofweek(trav_date) in (1, 7), null, 1)) as 'weekday trips'
from driver_log;
select * from trip_summary_view;