--首先把上边的结果生成临时表
select dzxl=substr(a.dzxl,1,4),a.com_code,b.name, sum_num=sum(a.hslsje-a.zzk) into #t from pszx_jxc_com_day a ,commod b
where a.com_code=b.code and a.rq>='01-jun-04' and a.rq<='22-jun-04'
and substr(a.dzxl,1,3) in('108','109','110','111')
group by substr(a.dzxl,1,4),a.com_code,b.name order by --查询
select * from #t t
where com_code in (select top 10 com_code from #t where dzlx=t.dzlx order by sum_num desc)
select dzxl=substr(a.dzxl,1,4),a.com_code,b.name, sum_num=sum(a.hslsje-a.zzk) into #t from pszx_jxc_com_day a ,commod b
where a.com_code=b.code and a.rq>='01-jun-04' and a.rq<='22-jun-04'
and substr(a.dzxl,1,3) in('108','109','110','111')
group by substr(a.dzxl,1,4),a.com_code,b.name order by --查询
select * from #t t
where com_code in (select top 10 com_code from #t where dzlx=t.dzlx order by sum_num desc)
解决方案 »
- 刚才视图问错了,对不起大家,再起一帖
- 如何把sqlserver表的内容导入到access相同名字的表中???
- 这个能否实现?
- sql 如何得到每个物料的最新订单日期(转贴-问题)
- 我的SQLserver在xp上总是安装错误
- 整合10个数据库
- 怎么用一条语句把我group by id的各个id的第一条一起取出来,就是对应的各个id就取一条
- 怎样才能使在VFP的表单上按那个“X”时,同时把VFP关闭,不然会出现程序关了,VFP还开着,却不能关的现象
- 如何在一视图中实现判断输出--(if a is null then '' else a end if)
- 一个diagrams的问题,高手请进!
- 请诸位指点,急!(怎样用C#编写倒数据?)
- 数据还原问题
同意楼上。