由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - union function differenct between sql server 2005 and 2008?
相关主题
How to query a treeLate afternoon 腦不好使
求教:怎么在select 出的结果里加一行请教怎么来log duration of a MYSQL procedure?
请问这个update query有什么问题?[转载] access问题请教
问个问题data analyst in HR department
这2个query哪个快点,为啥oracle和XML
A sql questiona complex sql query, high hand help!!!
[转载] Can anyone interpret this simple SQL?java sql help!
急,SQL2005, 怎么查过去一小时里run过的所有query?如何完成这个sql?
相关话题的讨论汇总
话题: union话题: select话题: where话题: criteria话题: query
进入Database版参与讨论
1 (共1页)
i******7
发帖数: 421
1
有这样一个table A
ReportYear, ReportMonth, Reportdate, and others
以前用sql server 2005, 用以下query
Select year,month,date, other from A
Where criteria 1
Union
Select year,month,date, other from A
Where criteria 2
Query result自动按照年,月,日的顺序排列。
现在用sql server 2008,一样的query 得出的结果不是按照年,月,日由小到大的顺序
排列了。日期在后面可能排在前,这是为什么?
谢谢!
B*****g
发帖数: 34098
2
algorithm changed.
same thing happened for oracle 9i to oracle 10g.
If you need order, add order by

【在 i******7 的大作中提到】
: 有这样一个table A
: ReportYear, ReportMonth, Reportdate, and others
: 以前用sql server 2005, 用以下query
: Select year,month,date, other from A
: Where criteria 1
: Union
: Select year,month,date, other from A
: Where criteria 2
: Query result自动按照年,月,日的顺序排列。
: 现在用sql server 2008,一样的query 得出的结果不是按照年,月,日由小到大的顺序

i****a
发帖数: 36252
3
Select year,month,date, other from A
Where criteria = 1
or criteria = 2
order by criteria, year, month, date

【在 i******7 的大作中提到】
: 有这样一个table A
: ReportYear, ReportMonth, Reportdate, and others
: 以前用sql server 2005, 用以下query
: Select year,month,date, other from A
: Where criteria 1
: Union
: Select year,month,date, other from A
: Where criteria 2
: Query result自动按照年,月,日的顺序排列。
: 现在用sql server 2008,一样的query 得出的结果不是按照年,月,日由小到大的顺序

i****a
发帖数: 36252
4
is that the cause, or is it because the records' physical order changed
when migrating the database from 2005 to 2008?

【在 B*****g 的大作中提到】
: algorithm changed.
: same thing happened for oracle 9i to oracle 10g.
: If you need order, add order by

p*********d
发帖数: 136
5
Is this the case, Beijing? Definitely if the physical order changed the
query result set order will change too if no ORDER BY clause specified.

【在 i****a 的大作中提到】
: is that the cause, or is it because the records' physical order changed
: when migrating the database from 2005 to 2008?

h**l
发帖数: 99
6
This one is NOT the same as the union query.
Union removes duplicates.

【在 i****a 的大作中提到】
: Select year,month,date, other from A
: Where criteria = 1
: or criteria = 2
: order by criteria, year, month, date

i****a
发帖数: 36252
7
good catch
then:
Select year,month,date, other from A
Where criteria 1
Union
Select year,month,date, other from A
Where criteria 2
order by year, month, date

【在 h**l 的大作中提到】
: This one is NOT the same as the union query.
: Union removes duplicates.

1 (共1页)
进入Database版参与讨论
相关主题
如何完成这个sql?这2个query哪个快点,为啥
One sql question help!A sql question
pls help me in this Sql query[转载] Can anyone interpret this simple SQL?
ask for help with a simple query!!!急,SQL2005, 怎么查过去一小时里run过的所有query?
How to query a treeLate afternoon 腦不好使
求教:怎么在select 出的结果里加一行请教怎么来log duration of a MYSQL procedure?
请问这个update query有什么问题?[转载] access问题请教
问个问题data analyst in HR department
相关话题的讨论汇总
话题: union话题: select话题: where话题: criteria话题: query