我想按照物资的名称和规格查找出物资的名称、规格、单价和日期和物资总量?怎么办?谢谢!!! 大至上这样处理就可以了的:select 名称,规格,sum(数量),avg(单价),max(日期)from 你的表group by 名称,规格说明:数量求总数,单价取平均单价,日期取最后发生日期 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 delcare @时间段 datetime select 单价,日期,count(*)from yourtablegroup by 名称,规格where (getdate()-入库日期)<=@时间段 如果想把名称和规格也查找出来,怎么办?select 名称,规格,单价,日期,count(*)from yourtablegroup by 名称,规格where (getdate()-入库日期)<=@时间段是不行的!!!谢谢!!! delcare @时间段 datetimeselect 名称,规格,单价,数量,日期 from yourtable where '计数'= (select count(*) from yourtable group by 名称,规格 where (getdate()-入库日期)<=@时间段) delcare @时间段 intset @时间段=50 --查询50天内的记录select 名称,规格,单价,日期,sum(数量) --求数量总和应该用sum,count是计数from 你的表where (getdate()-入库日期)<=@时间段group by 名称,规格,单价 delcare @时间段 intset @时间段=50 --查询50天内的记录select 名称,规格,avg(单价),日期,sum(数量) --如果你只想根据名称,规格分组统计的话from 你的表where (getdate()-入库日期)<=@时间段group by 名称,规格 rozjcxc(邹建):如果只按照名称、规格分组,但是还要select出单价,sum(数量)!!怎么办?? 可以啊,你将单价放在聚合函数中就行了,不然没办法好想.select 名称,规格,avg(单价,sum(数量)from 你的表where (getdate()-入库日期)<=@时间段group by 名称,规格 select *,(select sum(数量) from 物资表 where 名称=@名称 and 规格=@规格) 物资总量 from 物资表 where 名称=@名称 and 规格=@规格 select *,tem.物资总量 from 物资表,(select sum(数量) 物资总量 from 物资表 where 名称=@名称 and 规格=@规格) tem where 名称=@名称 and 规格=@规格 to pengdali(大力 V2.0) 好象不行啊!! 请各位数据库高手都来看看 【在线等】求助 关于如何获得插入大量数据的使用时间 求sql语句!多谢了。 ? 这个整个语句段实现什么功能,请详细解释??? 求一算年龄的sqlserver函数 还有一道。。。 大表的优化 按10分钟分组查询的问题 前辈们指导~sql数据库300万条数据查询 请问,有关VFP与SQL 在sqlserver2000和win98操作系统下,不能正常配置数据源,在线等,非常感谢 全文检索的问题,formsof为什麽不起作用?
select 单价,日期,count(*)
from yourtable
group by 名称,规格
where (getdate()-入库日期)<=@时间段
select 名称,规格,单价,日期,count(*)
from yourtable
group by 名称,规格
where (getdate()-入库日期)<=@时间段
是不行的!!!
谢谢!!!
select 名称,规格,单价,数量,日期 from yourtable where '计数'=
(select count(*)
from yourtable
group by 名称,规格
where (getdate()-入库日期)<=@时间段)
set @时间段=50 --查询50天内的记录select 名称,规格,单价,日期,sum(数量) --求数量总和应该用sum,count是计数
from 你的表
where (getdate()-入库日期)<=@时间段
group by 名称,规格,单价
set @时间段=50 --查询50天内的记录select 名称,规格,avg(单价),日期,sum(数量) --如果你只想根据名称,规格分组统计的话
from 你的表
where (getdate()-入库日期)<=@时间段
group by 名称,规格
如果只按照名称、规格分组,但是还要select出单价,sum(数量)!!
怎么办??
from 你的表
where (getdate()-入库日期)<=@时间段
group by 名称,规格
好象不行啊!!