婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > MSSQL 多字段根據范圍求最大值實現方法

MSSQL 多字段根據范圍求最大值實現方法

熱門標簽:知名電銷機器人價格 電銷機器人公司 需要哪些牌照 長沙智能外呼系統 廣東防封卡外呼系統原理是什么 湖南電腦外呼系統平臺 外呼系統改進 分享百度地圖標注多個位置 地圖標注牌 菏澤語音電銷機器人加盟公司

-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 15:08:41

declare @T table([Col1] int,[Col2] int,[Col3] int,[Col4] int,[Col5] int,[Col6] int,[Col7] int)
Insert @T
select 1,10,20,30,40,50,60 union all
select 2,60,30,45,20,52,85 union all
select 3,87,56,65,41,14,21
--方法1
select [col1],
       max([col2])maxcol
from
 (select [col1],[col2] from @t
  union all
  select [col1],[col3] from @t
  union all
  select [col1],[col4] from @t
  union all
  select [col1],[col5] from @t
  union all
  select [col1],[col6] from @t
  union all
  select [col1],[col7] from @t
 )T
where [col2] between 20 and 60  --條件限制
group by [col1]
/*
col1        maxcol
----------- -----------
1           60
2           60
3           56

(3 個資料列受到影響)

*/
--方法2
select [col1],
       (select max([col2])from
       (
        select [col2]
        union all select [col3]
        union all select [col4]
        union all select [col5]
        union all select [col6]
        union all select [col7]
       )T
       where [col2] between 20 and 60) as maxcol --指定查詢範圍
from @t
/*
(3 個資料列受到影響)
col1        maxcol
----------- -----------
1           60
2           60
3           56
*/

標簽:呼和浩特 福建 商洛 泉州 西寧 天水 珠海 美容院

巨人網絡通訊聲明:本文標題《MSSQL 多字段根據范圍求最大值實現方法》,本文關鍵詞  MSSQL,多,字段,根據,范圍,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《MSSQL 多字段根據范圍求最大值實現方法》相關的同類信息!
  • 本頁收集關于MSSQL 多字段根據范圍求最大值實現方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 阿鲁科尔沁旗| 涿鹿县| 巍山| 平武县| 教育| 元阳县| 焦作市| 双鸭山市| 博野县| 龙口市| 鹤壁市| 乡宁县| 南充市| 阿拉善左旗| 青神县| 中阳县| 宁乡县| 临泽县| 天峻县| 顺平县| 古丈县| 甘德县| 来安县| 尚志市| 凉城县| 汉中市| 吉林市| 呼伦贝尔市| 建水县| 绥阳县| 延吉市| 汪清县| 清涧县| 汝南县| 邯郸县| 宾川县| 克山县| 都兰县| 新竹市| 南丹县| 青神县|