日期:2014-05-19  浏览次数:20665 次

关于SQL中sum()的问题
create   table   productinfo   (
productinfo_id int   identity(1000,1) not   null,
entry_id varchar(14) null,
inportime char(5)   default   convert(char(5),   getdate(),   108),
func11 int   DEFAULT   0,
func12 int   DEFAULT   0,
func13 int   DEFAULT   0,
func14 int   DEFAULT   0,
func15 int   DEFAULT   0,
                  sums   as   func11+func12+func13+func14+func15
)
输入数据后
                                                      f1         f2       f3           f4         f5           sums
1000   200701040001 10:20 0           1           0           0           1             2
1001   200701040002 10:25 0           0           1           0           0             1
1002   200701040003 10:35 0           0           0           0           0             0
1003   200701040004 10:40 0           0           0           0           0             0
1004   200701040002 10:45 0           0           0           0           0             0
1005   200701040001 10:50 0           0           0           0           0             0

现在要得到有多少条数据,怎么做?



------解决方案--------------------
select count(entry_id)
from productinfo
group by entry_id