婷婷综合国产,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 多字段根據范圍求最大值實現方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 武清区| 临桂县| 凤凰县| 莱芜市| 红桥区| 文成县| 内丘县| 阿克陶县| 喀喇沁旗| 衡南县| 教育| 右玉县| 陕西省| 沂南县| 镇原县| 会泽县| 汽车| 嘉鱼县| 大竹县| 平利县| 建阳市| 宁安市| 芦溪县| 武鸣县| 嘉祥县| 宜都市| 揭东县| 宣恩县| 都兰县| 灵川县| 关岭| 湛江市| 宝鸡市| 静安区| 临泽县| 怀宁县| 郎溪县| 毕节市| 望谟县| 武宁县| 金秀|