聚合函数一定要和group by子句连用么  如果不用得话  只用 select *  from  该怎么写..

解决方案 »

  1.   

    如果只有一列就不用了 如 select count(*) from table
      

  2.   

    只用select *的话就写成子查询
      

  3.   

    -->2005可以与窗口函数over一起用:select count(1)over(partition by object_id) as 列数, * from sys.columns 
      

  4.   

    你要查看的列 要不在聚合函数里,要不在group by 里例子 table student 
    列名  id name  课程  成绩   select sum(成绩) from student   正确  select name, 课程 ,sum(成绩) from student group by 课程     错误 
         错误信息 :name 应包含分组group by 中 
       select name, 课程 ,sum(成绩) from student group by name,课程   正确