我现在有一张表字段分别是“
companyname 状态(querystate) productname 等等现在我要写一个查询语句既要把公司的总数统计出来,又要算出状态为1的公司呢?我写了一条语句 麻烦各位大哥帮忙看看为什么不行,请各位高手指教!select companyname,count(companyname),querystate,count(querystate) , count(QueryState)as msg2 from productcode group by companyname ,querystate
companyname 状态(querystate) productname 等等现在我要写一个查询语句既要把公司的总数统计出来,又要算出状态为1的公司呢?我写了一条语句 麻烦各位大哥帮忙看看为什么不行,请各位高手指教!select companyname,count(companyname),querystate,count(querystate) , count(QueryState)as msg2 from productcode group by companyname ,querystate
select count(companyname) from productcode //取得总数
select count(querystate) from productcode where =1querystate=1
select count(companyname) as 公司总数,count(querystate)as 状态
from productcode
where querystate='1'
group by querystate
select count(querystate) as 状态 from productcode where querystate='1' group by querystate