楼上的是可以
要是数据少可以
但我的数据有20000条以上,并且类似的表有4张。。
不用SQL不行的
要是数据少可以
但我的数据有20000条以上,并且类似的表有4张。。
不用SQL不行的
解决方案 »
- 一个数据存储的基础知识的问题
- sqlserver数据库存储过程返回值只能是integer类型吗? 不能返回字符串吗?
- |zyciis| group by 后,怎么再打某一字段进行group by 谢谢
- 请教更新数据问题
- sqlserver设置权限时,如何设置禁止导入导出???
- 一个数据库同步问题
- 新手提问,急求解答!
- 高分求高手写一段高性能的SQL
- SQL难题。。。〔4〕
- 新人求帮助,把数据文件中的表的blob提取成cvs或者xls文件
- MSSQL群,欢迎大家加入4441311
- 发现一个奇怪的问题: 可以在查询分析器里面建立一个字段 numeric(38) 型的, 但是只可以用视图的方式在企业管理器里面建立一个 numeric
张三 15 女 12:00
张三 15 女 1:00
张三 15 女 15:00
李四 16 男 15:21
李四 16 男 14:15
李四 16 男 17:51
李四 16 男 12:11
王五 17 男 15:15
王五 17 男 18:02
王五 17 男 12:02
王五 17 男 3:03
李四 16 男 15:15
张三 15 女 12:12
张三 15 女 7:7如过是这样的话上面的SQL语句就不可以了。
对于上面的表要的到的就是登陆网站的人的名单再赐教~!
from hhh a
where 登陆网站时间<>(select max(登陆网站时间) from hhh where 姓名=a.姓名)
insert c(姓名,年纪,性别,登陆网站时间) select distinct a.姓名,a.年纪,a.性别,a.登陆网站时间 from a,b where a.姓名=b.姓名
或许我没看清楚楼主的意思了
from hhh a
where 登陆网站时间<>(select max(登陆网站时间) from hhh where 姓名=a.姓名)这种方法,我想是可以的,但如果数据上万条的话,我想要比用临时表慢
试了,好象是把hhh 表有复制到newtable了。
select distinct 姓名,年纪,性别 into <newtable> from hhh group by 姓名,年纪,性别
注意这里没有选择“登陆网站时间”
insert t1(a,b)
select 'aa','bb'
union all select 'a1','bgb'
union all select 'aa','bb'
union all select 'a2','bb'
union all select 'aa3','beeb'
union all select 'aa','bb'
union all select 'a2','bb'delete t1
where id not in
(select min(id) as id from t1 group by a,b)----------------a,b重复.-----------select * from t1drop table t1/*
id a b
------------------
0 aa bb
1 a1 bgb
3 a2 bb
4 aa3 beeb*/
先增加标识键.
select *,id identity(int,1,1) into #t from hh然后再执行上面的操作..........