avatar
c*k
1
I have a problem in creating a SQL statement. Can anyone help me?
Suppose I have a table as below:
id min max
1 7 11
2 9 12
3 14 18
4 10 13
I would like to merge the min and max and finally get this:
min max
7 13
14 18
How can I create a SQL statement to get that? Is it possible? Thanks in
advance!
avatar
b*l
2
select min(min), min(max) from table
union
select max(min), max(max) from table

【在 c********k 的大作中提到】
: I have a problem in creating a SQL statement. Can anyone help me?
: Suppose I have a table as below:
: id min max
: 1 7 11
: 2 9 12
: 3 14 18
: 4 10 13
: I would like to merge the min and max and finally get this:
: min max
: 7 13

avatar
c*k
3
No. I didn't mean that. I mean
[7, 11] U [9, 12] U [14, 18] U [10, 13] = [7, 13] U [14, 18]
It is possible there are much more rows in that table, and then the
result will not be only two rows.

【在 b******l 的大作中提到】
: select min(min), min(max) from table
: union
: select max(min), max(max) from table

avatar
n*a
4

Explain your U operator. How does it work?????
Or give more examples, like another data set
where the final result is more than 2 rows.

【在 c********k 的大作中提到】
: No. I didn't mean that. I mean
: [7, 11] U [9, 12] U [14, 18] U [10, 13] = [7, 13] U [14, 18]
: It is possible there are much more rows in that table, and then the
: result will not be only two rows.

avatar
k*t
5
好象是数集里面的算符

Explain your U operator. How does it work?????
Or give more examples, like another data set
where the final result is more than 2 rows.

【在 n********a 的大作中提到】
:
: Explain your U operator. How does it work?????
: Or give more examples, like another data set
: where the final result is more than 2 rows.

avatar
c*k
6
Yes, set union operator

【在 k******t 的大作中提到】
: 好象是数集里面的算符
:
: Explain your U operator. How does it work?????
: Or give more examples, like another data set
: where the final result is more than 2 rows.

avatar
k*t
7
i guess you need not only sql query

【在 c********k 的大作中提到】
: Yes, set union operator
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。