数据库字段分别是id,count,year,month,date,其中id和year,month,date联合做主键,统计每条广告的点击量。
现在要求统计一段时间内的一条广告的点击量,
在数据库中的sql语句是select id,sum(count)
from lava_HitCount
where
year >= 2010 and 2010 >= year
and month >= 12 and 12 >= month
and date >= 8 and 10 >= date
group by id如何将sum(count)值显示到DataGrid中?
现在要求统计一段时间内的一条广告的点击量,
在数据库中的sql语句是select id,sum(count)
from lava_HitCount
where
year >= 2010 and 2010 >= year
and month >= 12 and 12 >= month
and date >= 8 and 10 >= date
group by id如何将sum(count)值显示到DataGrid中?
比如id=1的广告今天被点击一次,昨天也被点击一次,如果统计这两天的点击量,则直接显示1条id=1的数据,现在我想知道怎么能把这个点击量2显示在DataGrid中?
from lava_HitCount
where
year >= 2010 and 2010 >= year
and month >= 12 and 12 >= month
and date >= 8 and 10 >= date
group by id,year,month,date这样就行了,你可以在DataGrid里他年月日等信息也显示出来。
select id,sum(count) as count
from lava_HitCount
where
year >= 2010 and 2010 >= year
and month >= 12 and 12 >= month
and date >= 8 and 10 >= date
group by id
--把count当做字段,像平常那样绑定就可以!--
ds.Tables[0].Columns.Add("count");
row["count"]=sel_count();