select
t.phone,
t.re,
[count] = (select count(1) from 表A where phone=t.phone)
from
表A t
where
t.type = 1
and
not exists(select 1 from 表A where phone=t.phone and id>t.id)
order by
t.phone
t.phone,
t.re,
[count] = (select count(1) from 表A where phone=t.phone)
from
表A t
where
t.type = 1
and
not exists(select 1 from 表A where phone=t.phone and id>t.id)
order by
t.phone
解决方案 »
- SQL Server 2005安装过程中出现错误:证书链是由不受信任的颁发机构颁发的。
- 求sql 存储过程
- 有关sql2000的两个问题请教
- 无法定位序数29于动态链接库odbcbcp.dll
- where name="sh" and id between 2 and 50 ;为什么不可以?该怎么写?
- 两个标示列应该如何解决
- 再问,为什么 varchar(8000)只能存 4000个英文字符
- 到目前写过的最复杂的sql语句,大家看看能否简化
- 发了几天了,无人问津。。。。SQL全文索引问题!求高手解答
- 急急急!!!关于Foxbase中的数据类型转换问题。。。急需帮忙:)
- 怎么查看临时表里的内容?
- 求一SQL
t.phone,
t.re,
[count] = (select count(1) from 表A where phone=t.phone and type=t.type)
from
表A t
where
t.type = 1
and
not exists(select 1 from 表A where phone=t.phone and type=t.type and id>t.id)
order by
t.phone
,max(re) as 're'
,count(1) as 'count'
from A
where type=1
group by phone
order by phone