![]() |
#2
tlliqi2015-01-08 09:23
|
表:
ID price1 price2 price3
19415 61 90 90
03892 60 72 85
05749 60 120 190
06166 60 178 394
06447 60 124 224
题目:求横向的最小值。
答案:
select [ID],
[MINIPrice]=(select min([price1])
from (select [price1]
union all select [price2]
union all select [price3]
union all select [price4])T)
from table
求高手解析下答案,谢谢啦!
比如,这里用了union链接多个表,select后面为什么没有from,还有这里只用了1个min函数为什么能求多行的最小值。刚学sql,还请大神传授。
[ 本帖最后由 dqk911 于 2015-1-7 16:42 编辑 ]