久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

表 B 范圍內表 A 值的 SQL 連接

SQL Join on Table A value within Table B range(表 B 范圍內表 A 值的 SQL 連接)
本文介紹了表 B 范圍內表 A 值的 SQL 連接的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有兩個表格,可以在附圖中看到.

I have two tables that can be seen in accompanying image.

表 A 包含部門、月份平均值.

表 B 包含 RangeStartRangeEnd 和 <強>顏色.

Table B contains Month, Year, RangeStart, RangeEnd and Colour.

如果您查看表 B 的屏幕截圖,您會看到每個月都有綠色、黃色、橙色和紅色值.你也有一個范圍.

If you look at the screen shot of Table B, you will see for each Month you have a Green, Yellow, Orange and Red value. You also have a range.

我需要什么......

我需要在表 A 上新建一個名為顏色"的列.在此列中,我需要綠色、黃色、橙色或紅色.為月份分配哪種顏色的決定因素將是平均"列.

I need a new column on Table A named 'Colour'. In this column, I need either Green, Yellow, Orange or Red. The deciding factor on which colour is assigned to the month will be the 'Average' column.

例如:

DepartmentA 的 5 月平均值等于 0.96在引用表 B 時,我可以看到第 8 行,0.75+ 將是它適合的范圍.因此,紅色是我想放在 表 A 中與 Mays 平均值相鄰的顏色.

DepartmentA for May's Average is equal to 0.96 Upon referencing Table B, I can see that line 8, 0.75+ will be the range this fits into. Therefore Red is the colour I want placed in table A next to Mays average.

我已將每月最高范圍的 RangeEnd 保留為 NULL,因為它基本上是 75+,任何大于 0.75 的位置都在此處.

I have left RangeEnd for the highest range per month as NULL as it is basically 75+, anything greater than 0.75 slots in here.

誰能指出我正確的方向,而且不會太耗時.

Can anyone point me in the right direction that is not too time consuming.

推薦答案

你可以直接使用:

select *
from table a
    join table b
        on a.month = b.month
           and a.average between b.rangestart and isnull(b.rangeend,10000) -- 100000 = greater than max value

這篇關于表 B 范圍內表 A 值的 SQL 連接的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 久久亚洲一区二区三区四区 | 国产精品精品视频一区二区三区 | 97影院在线午夜 | 亚洲一区二区av | 国产精品久久 | 国产成年人视频 | 国产精品中文字幕在线 | jⅰzz亚洲| 日日碰狠狠躁久久躁婷婷 | 国产欧美日韩精品一区二区三区 | 久久久久久久久淑女av国产精品 | 中日字幕大片在线播放 | 久久只有精品 | 精品福利在线 | 中文字幕欧美一区 | 国产区免费视频 | 欧美精品一区二区三区一线天视频 | 久久成人午夜 | 国产精品亚洲精品日韩已方 | 成人福利电影 | 欧美一区二不卡视频 | 一级毛片视频在线观看 | 亚洲欧美综合 | 97av| 免费大黄视频 | 国产国拍亚洲精品av | 黄色在线免费观看视频网站 | 精品欧美一区免费观看α√ | 国产精品黄色 | 欧美精品一区三区 | av免费网址| 欧美日韩在线一区二区三区 | 亚洲视频在线一区 | 亚洲精品视频一区二区三区 | 欧美日韩综合 | 中文字幕免费 | 国产精品福利在线 | av网站观看| 日韩av一区二区在线观看 | 精品国产欧美一区二区三区不卡 | 精品国产免费人成在线观看 |