我有一个场景,其中我有一个表A,它具有7行的固定数据,如下所示:
Range 0-59
60-119
120-179
180-239
240-299
300-499
500+
现在我有另一个表B,其中我有单位..我必须显示表A的所有记录,然后显示该范围内特定值和休息范围的单位为0或null。
因此,为了连接这两个表,我在表B中创建了一个带有case语句的列,以便行具有作为列的范围:
(case
when v between '0' and '59' then '0 to 59'
when v between '60' and '119' then '60 to 119'
when V between '120' and '179' then '120 to 179'
when v between '180' and '239' then '180 to 239'
when v between '240' and '299' then '240 to 299'
when v between '300' and '499' then '300 to 499'
when v >'500' then '500+'
else 'other'
end)
然后我加入了这两个表......现在当我填充这些记录时,我得到的匹配行只有一个....我的要求是显示所有范围......
请参阅以下屏幕截图,了解情景说明: