Access数据库查询问题
时间:2011-12-02
来源:互联网
HonorCountry 表名
ID 是主键,数字
ID 里面的数字并不一定是连续的数字
sql怎么写呢??? 求助!
作者: dt891030 发布时间: 2011-12-02
作者: fredrickhu 发布时间: 2011-12-02
要不楼主就用程序实现吧
作者: pengxuan 发布时间: 2011-12-02
SQL code
create table tb(id int,dt varchar(10)) insert into tb select 1,'aa' insert into tb select 2,'cc2' insert into tb select 4,'fsa' insert into tb select 7,'fe' insert into tb select 12,'ewr' insert into tb select 13,'tr' insert into tb select 15,'ge' insert into tb select 22,'he' go select id,dt from (select *,(select count(*) from tb where id<=a.id) as rn from tb a)t where rn%2=0 --ACCESS 中: select id,dt from (select *,(select count(*) from tb where id<=a.id) as rn from tb a)t where rn mod 2=0 /* id dt ----------- ---------- 2 cc2 7 fe 13 tr 22 he (4 行受影响) */ go drop table tb
作者: qianjin036a 发布时间: 2011-12-02
作者: qianjin036a 发布时间: 2011-12-02
作者: dt891030 发布时间: 2011-12-02
1.3.5.7.8.9.12.13.15
1.5.8.12.15
3.7.9.13
作者: dt891030 发布时间: 2011-12-02
如果ID并不一定是对半的奇数和偶数呢
这里是说的排列顺序上的奇数偶数,你不是要隔行取吗,你仔细看一看结果的ID.
作者: qianjin036a 发布时间: 2011-12-02
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28