c********k 发帖数: 74 | 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! | b******l 发帖数: 261 | 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
| c********k 发帖数: 74 | 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
| n********a 发帖数: 68 | 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.
| k******t 发帖数: 28 | 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.
| c********k 发帖数: 74 | 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.
| k******t 发帖数: 28 | 7 i guess you need not only sql query
【在 c********k 的大作中提到】 : Yes, set union operator
|
|