=======SQL语句请教各路朋友,大家请进==========

zhlym 2005-05-24 12:09:47
我如下这句要改成只取pubtable库的sellautoid字段唯一值,应怎改?
select a.autoid,a.monberin,a.carno,a.carno1,a.bx_date,a.bx_time,a.yj_date,a.yj_time,a.wx_suxi,b.indate,b.antrueman,b.enddate from reparein a, pubtable b where a.officeid='"&Session("officeid")&"' and b.officeid='"&Session("officeid")&"' and a.monberin=b.sellautoid and a.monthjie='0' and b.indate between '"&sdate1&"' and '"&sdate2&"' and b.antrue=2 order by a.monberin desc

请大家看清楚我的要求,不要select distinct sellautoid from pubtable出现这种情况
...全文
83 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhlym 2005-05-24
  • 打赏
  • 举报
回复
TO 各位

第一: 不要为了得分乱写呀

第二: 我想要例子, 还望大家回贴时贴出例子
hbhbhbhbhb1021 2005-05-24
  • 打赏
  • 举报
回复
连接的时候选择左连接或右连接,不要全连接就可以了
tianch 2005-05-24
  • 打赏
  • 举报
回复
select sellautoid from pubtable group by sellautoid
jarraytan 2005-05-24
  • 打赏
  • 举报
回复
啥意思啊,楼主,没看明白.
zhlym 2005-05-24
  • 打赏
  • 举报
回复
还是我自己想到办法了,汗,谁顶有分现在
zhlym 2005-05-24
  • 打赏
  • 举报
回复
TO zhangxian_gege(张仙)

你的方法一样不行咧
chjpeng 2005-05-24
  • 打赏
  • 举报
回复
建议你搜一下group by的用法
zhangxian_gege 2005-05-24
  • 打赏
  • 举报
回复
select a.autoid,a.monberin,a.carno,a.carno1,a.bx_date,a.bx_time,a.yj_date,a.yj_time,a.wx_suxi,b.indate,b.antrueman,b.enddate from

reparein a left outer join pubtable b on a.officeid='"&Session("officeid")&"' and b.officeid='"&Session("officeid")&"'

and a.monberin=b.sellautoid and a.monthjie='0' and b.indate between '"&sdate1&"' and '"&sdate2&"' and

b.antrue=2 order by a.monberin desc
或者以下语句

select a.autoid,a.monberin,a.carno,a.carno1,a.bx_date,a.bx_time,a.yj_date,a.yj_time,a.wx_suxi,b.indate,b.antrueman,b.enddate from

pubtable a left outer join reparein b on a.officeid='"&Session("officeid")&"' and b.officeid='"&Session("officeid")&"'

and b.monberin=a.sellautoid and a.monthjie='0' and b.indate between '"&sdate1&"' and '"&sdate2&"' and

b.antrue=2 order by a.monberin desc

因为我没有具体的表结构,所以只能这样写了

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧