34,590
社区成员
发帖
与我相关
我的任务
分享
declare @infocount int,@cnt int
select @infocount=0,@cnt=0
select @cnt=count(id) from table1
set @infocount=@infocount+@cnt
select @cnt=count(id) from table2
set @infocount=@infocount+@cnt
select @infocount
declare @datetemp table(classid int)--表变量
insert into @datetemp select distinct(enterprisecolumnclass.classid)
from enterprisecolumnclass,enterprisecolumn
where status=0 and enterpriseid=137 and enterprisecolumn.id=enterprisecolumnclass.enterprisecolumnid
declare @infocount int
set @infocount=0
select @infocount=count(ProductTemp.id) from ProductTemp,ProductTemp_class,@datetemp t
where ProductTemp.name <>'' and ProductTemp.name is not null and ProductTemp_class.classid=t.classid and ProductTemp.id=ProductTemp_class.ProductTempid
and datediff(d,getdate(),ProductTemp.createtime)=0
select @infocount
select @infocount =sum(count(ProductTemp.id)) from ProductTemp,ProductTemp_class,@datetemp t
where ProductTemp.name <>'' and ProductTemp.name is not null and ProductTemp_class.classid=t.classid and ProductTemp.id=ProductTemp_class.ProductTempid
and datediff(d,getdate(),ProductTemp.createtime)=0
select @infocount
请给出表结构,测试数据,具体算法和结果,谢谢。
--不太明白你说的。??
sum(count(ProductTemp.id))