select shopid 零售店,month 月份,sum(num) 销售数量
from sales
where month in (1...)
group by shopid ,month
order by month ,shopid ,sum(num) ???
from sales
where month in (1...)
group by shopid ,month
order by month ,shopid ,sum(num) ???
解决方案 »
- 更新数据时一个小问题
- 问一个很简单的SQL写法但是很常用
- 问两个基础但又不常注意的问题,帮忙,谢谢。
- sqlserver2000中如何把查询的结果用别的值替换掉
- 用友财务通用户名无法设密码,随便装个客户端软件就能看数据库,怎么办呀?
- 信息同步的问题.+++++++++++++++++++++++++++++标题要长
- 关于OPENROWSET的问题
- 随机选出3个姓名不同的人,并显示各个字段?
- access表与mssql表中数据同步的难题,大侠们有何高招?
- sqlserver的最近耗费大量资源的查询里面,执行次数/分钟 的数值都很高,这样正常么?
- ADO版本
- 用ACCESS做为网络数据库会出现什么问题,这个问题很急,有特别详细的回答者,可另外再送分
from sales
where month in (1...)
group by shopid ,month
having sum(num)> 一定值
order by month ,shopid ,sum(num)
select 1 a,4 b,120 c
union
select 1 a,5 b,110 c
union
select 1 a,6 b,80 c
union
select 1 a,7 b,101 c
union
select 1 a,8 b,120 c
union
select 1 a,9 b,210 c
union
select 1 a,10 b,21 c
go
select * into #t from t
go--下面是取连续3个月大于100的资料
select * from #t where exists( select t.* from
(select a.a a1,a.b b1,a.c c1,b.a a2,b.b b2,b.c c2,c.a a3,c.b b3,c.c c3
from #t a cross join #t b cross join #t c
where a.b<b.b and b.b<c.b) t
where t.b1=t.b2-1 and t.b2=t.b3-1 and c1>100 and c2>100 and c3>100
and (t.b1=#t.b or t.b2=#t.b or t.b3=#t.b)
)drop view t
go
drop table #t
go
表名:shop 字段一:ID(int) month(varchar(10))Num(int) ID month Num
a 01 125
a 02 198
a 03 109
a 04 160
b 01 100
b 02 106
b 03 120
b 04 160
c 01 102
c 02 98
c 03 160
c 04 130
d 01 89
d 02 110
d 03 123
d 04 150
要求:查找出连续三个月数量都大于110的商家。