检索sql server表的数据错误

时间:2012-03-23 07:31:55

标签: .net sql-server-2008 grid

my sql table data is 

column names & their datatypes are

column name           Datatype

installation_id        int(primarykey,identity(1,1))
Assignto               varchar 
customer_address       "
customer_contactno     "
package_details        "

1    ISP    N.G.O Colony    9841612124  Extended for 6 mnths
2    FE K.K Nagar   9865015695  expired
55  ISP02   aa          1234567890      aa
56  ISP02   asdf            0987654321      expired
57  ISP01   asdf        8907654321      Extended for 6 mnths
58  FE01    asdf        6789054321      expired
59  ISP02   asdf            5432109999      expired
60  DTo1    asdf            9999999999      expired

我想基于assignto列对列数据进行分组。但是我收到了错误?

我的查询是

通过Assignto选择*来自tn组

1 个答案:

答案 0 :(得分:0)

你不能按*分组。返回值必须在分组中或者是聚合。

Select AssignTo, Count(*) From tn Group by assignto