select top 10 * from bolemobile where Jobname='会计' and bestflag ='1'
union
select * from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1')
order by bestflag desc, lastupdate_time desc
用*不出错(上),但是单指定某几列就出错了“如果语句中包含 UNION 运算符,那么 ORDER BY 子句中的项就必须出现在选择列表中。”
union
select * from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1')
order by bestflag desc, lastupdate_time desc
用*不出错(上),但是单指定某几列就出错了“如果语句中包含 UNION 运算符,那么 ORDER BY 子句中的项就必须出现在选择列表中。”
解决方案 »
- C# asp.net如何实现批量下载
- 动态生成的CheckBoxList用CheckBox实现全选
- Repeat控件绑定数据,显示图片的问题!!!急急急
- 给JS联动设置初始选项
- 关于发送多个邮件的问题,求思路~~
- 简单但是急的问题。。。如何用javascript控制另外一个框架内的控件属性。
- asp.net2.0中TreeView问题(问题一旦解决马上给分)
- 谁帮我推荐一款.net或asp的英文论坛?版面要简洁
- 关于具有不同权限用户上传与下载文件的程序,现在已经有了一个用户的表,权限的情况可以通过在这个用户表反映出来,但是我不知道该从那里
- Ajax postback问题
- 这段SqlParameter添加到Command中用到foreach的作用是什么?
- 现在学asp.net 看哪几本书在实际开发中比较实用,学完干活没啥问题了
(
select top 10 * from bolemobile where Jobname='会计' and bestflag ='1'
union
select * from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1')
)
order by bestflag desc, lastupdate_time desc
select top 10 * from bolemobile where Jobname='会计' and bestflag ='1'
union
select * from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1') goselect * from myview order by bestflag desc, lastupdate_time desc
select * from table1 where id in (13,14)
union
select * from table1 where id in (12,22)
order by id desc
上面是对的select Department from table1 where id in (13,14)
union
select Department from table1 where id in (12,22)
order by id desc
上面是错的
ORDER BY items must appear in the select list if the statement contains a UNION operator.select Department,id from table1 where id in (13,14)
union
select Department,id from table1 where id in (12,22)
order by id desc
上面也是对的
用来 order 的字段需要出现在 select 中
union
select * from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1')
order by bestflag desc, lastupdate_time desc
这样是可以的 ,但是吧*改成某几列就不行了
(
select top 10 * from bolemobile where Jobname='会计' and bestflag ='1'
union
select * from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1')
)
order by bestflag desc, lastupdate_time desc
over
比如想选择col1,col2,col3,然后以bestflag desc, lastupdate_time 排序
则,
select col1,col2,col3
FROM
(
select top 10 col1,col2,col3,bestflag , lastupdate_time from bolemobile where Jobname='会计' and bestflag ='1'
union
select col1,col2,col3,bestflag , lastupdate_time from bolemobile where Jobname='会计' and bestflag not in (select bestflag from bolemobile where bestflag ='1')
)
order by bestflag desc, lastupdate_time desc