之前给朋友写了个问卷调查,用题号排序的,后来呢出现一个问题就是说排序的时候排出来是 1,10,11,2这样的。
select * from wenti where id = '"&id&"' order by wentith
后来呢改成
select * from wenti where id = '"&id&"' order by cast(wentith as int)
问题就解决了
然后我想依法炮制在联合查询中,
SELECT DISTINCT * from wenti as a,wentixx as b where a.id='"&id&"' and a.wentidm=b.wentidm and a.wentith<>'' and b.wtxxxh<>'' order by cast(a.wtth as int)
结果就是提示
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]如果指定了 SELECT DISTINCT,那么 ORDER BY 子句中的项就必须出现在选择列表中。
很疑虑,想问下各位达人这种情况应该如何处理:)
select * from wenti where id = '"&id&"' order by wentith
后来呢改成
select * from wenti where id = '"&id&"' order by cast(wentith as int)
问题就解决了
然后我想依法炮制在联合查询中,
SELECT DISTINCT * from wenti as a,wentixx as b where a.id='"&id&"' and a.wentidm=b.wentidm and a.wentith<>'' and b.wtxxxh<>'' order by cast(a.wtth as int)
结果就是提示
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]如果指定了 SELECT DISTINCT,那么 ORDER BY 子句中的项就必须出现在选择列表中。
很疑虑,想问下各位达人这种情况应该如何处理:)
解决方案 »
- 求SQL得改写
- (省份代码,城市代码,客户代码,销量,大类别,小类别) 想对客户进行小类别细分 想区分出每个城市每种大类别下销量排名前20%后20%中间60%客户 内有测试数据
- 简单的问题,帮帮忙~
- 关于模糊查询
- 标识递增量能不能设为一个随机的整数?
- sql server 2000升级到2008提示连接不到数据库
- SQL Server2000,数据修改后,修改后的数据全部消失
- 列行转换+统计排序问题,请问下表如何按总分排序(不包括平均分)?邹建兄等高手帮帮忙呀,谢谢啦
- 是不是中文版的sqlserver无法注册英文版的sqlserver?
- 请问如何取得表中间一部分记录?
- sql server2005修改表空间
- sql delete 语句
楼主那句话不能那么些,提示已经全部告诉你原因了。
稍微改下:
SELECT DISTINCT cast(a.wtth as int) AS RMARK,* from wenti a,wentixx b
where a.id='"&id&"' and a.wentidm = b.wentidm
and a.wentith <>'' and b.wtxxxh <>''
order by cast(a.wtth as int)
where a.id='"&id&"' and a.wentidm = b.wentidm
and a.wentith <>'' and b.wtxxxh <>''
order by a.with