- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有列 Age
的表格, Period
和 Year
.栏目Age
总是从 0 开始并且没有固定的最大值(我在这个例子中使用了 'Age' 0 到 30,但范围也可以是 0 到 100 等),值 Period
和 Year
只出现在特定年龄的特定行中。
然而在什么Age
Period
的值和 Year
出现,变化和解决方案因此应该是动态的。填写NULL
的最佳方式是什么?正确的值 Period
和 Year
?
我正在使用 SQL Server。
Age Period Year
-----------------
0 NULL NULL
1 NULL NULL
2 NULL NULL
3 NULL NULL
4 NULL NULL
5 NULL NULL
6 NULL NULL
7 NULL NULL
8 NULL NULL
9 NULL NULL
10 NULL NULL
11 NULL NULL
12 NULL NULL
13 NULL NULL
14 NULL NULL
15 NULL NULL
16 NULL NULL
17 NULL NULL
18 NULL NULL
19 NULL NULL
20 NULL NULL
21 46 2065
22 NULL NULL
23 NULL NULL
24 NULL NULL
25 NULL NULL
26 51 2070
27 NULL NULL
28 NULL NULL
29 NULL NULL
30 NULL NULL
结果应该是这样的,
Period
的数字和
Year
应该从
Period
的最后一个已知值增加和/或减少和
Year
.
Age Period Year
-----------------
0 25 2044
1 26 2045
2 27 2046
3 28 2047
4 29 2048
5 30 2049
6 31 2050
7 32 2051
8 33 2052
9 34 2053
10 35 2054
11 36 2055
12 37 2056
13 38 2057
14 39 2058
15 40 2059
16 41 2060
17 42 2061
18 43 2062
19 44 2063
20 45 2064
21 46 2065
22 47 2066
23 48 2067
24 49 2068
25 50 2069
26 51 2070
27 52 2071
28 53 2072
29 54 2073
30 55 2074
这是我的问题的更新,因为我没有详细说明我的要求:
Age
的不同组合。 ,
Period
和
Year
.我的起点永远是一个已知的
Age
,
Period
和
Year
组合。然而,组合
Age
= 21,
Period
= 46 和
Year
= 2065(或 26|51|2070 作为第二个组合)在我的示例中不是静态的。
Age
处的值= 21 可以是任何东西,例如
Period
= 2 和
Year
= 2021。无论组合(
Age
、
Period
、
Year
)是什么,解决方案都应该填补空白并完成从
Period
的已知值开始向上和向下计数的序列和
Year
.如果
Period
值序列变为负数,解应该返回
NULL
值,如果可能。
最佳答案
似乎你的年龄和年份总是相同的增量
所以
select age, isnull(period,age +25) Period, isnull(year,age+44) year
from yourtable
或标准函数合并(如戈登林诺夫所建议的)
select age, coalesce(period,age +25) Period, coalesce(year,age+44) year
from yourtable
关于sql - 填补 SQL Server 中年份序列的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63735259/
这个问题困扰了我一段时间,因为我一直在寻找一种有效的方法。基本上,我有一个数据框,每行都有一个来自实验的数据样本。我想这应该更多地被视为来自实验的日志文件,而不是用于分析的数据的最终版本。 我遇到的问
我有一个带有 IDENTITY 列的表 [Id] int IDENTITY(1, 1) NOT NULL 在添加/删除了一些行之后,我以 Id 值的差距结束: Id Name ---------
我有一个发票表,我在其中存储给定数据范围的发票(即 2012-01-01 到 2012-01-31 之间日期的发票 1)。现在有几天可能没有关联的发票,所以你会有 > ID | START_DATE
我正在查询 DATE 字段: SELECT DATE , FIELD2 , FIELD3 into Table_new FROM Table_old WHERE (crite
我有下表 data_users id | signed_up_at | product_id -------+---------------------------------
抱歉这个模糊的主题,但我想不出该放什么。 这是我的问题,我正在对一个表进行查询,该表返回与一天相关的项目计数。我想确保如果我对数据库进行查询,我总是会得到一定数量的行。例如,假设我有下表,其中包含人们
这个问题在这里已经有了答案: Why does CSS Grid layout add extra gaps between cells? (4 个答案) CSS-only masonry layo
给定数据框 df = pd.DataFrame(data=[[1,1,3],[1,2,6],[1,4,3],[2,2,6]],columns=['ID','Day','Value']) df Out[
我有以日期时间为索引的 Pandas DataFrame(从 .csv 加载).. 每天有/必须有一个条目。问题是我有差距,即有些日子我根本没有数据。在间隙中插入行(天)的最简单方法是什么?还有一种方
我只想用最简单的术语对 3D 数据集进行插值。线性插值,最近邻,这就足够了(这是开始一些算法,所以不需要准确估计)。 在新的 scipy 版本中,像 griddata 这样的东西会很有用,但目前我只有
我有一个类似于下面示例的多维数组,我想使用 Ruby 的 zip 方法将其组合在一起。当每个内部数组具有相同数量的元素时,我可以正常工作,但当它们的长度不同时,我会遇到问题。 在下面的示例中,第二组在
我有一个由日期和一些值组成的数组或对象: var flatData = [ { "date": "2012-05-26", "product": "apple" }, { "date
我有一个带有列 Age 的表格, Period和 Year .栏目Age总是从 0 开始并且没有固定的最大值(我在这个例子中使用了 'Age' 0 到 30,但范围也可以是 0 到 100 等),值
在 SQL Server 2014 中,我有一个如下所示的 Periods 表: | PeriodId | PeriodStart | PeriodEnd | -------------------
在 SQL Server 2014 中,我有一个如下所示的 Periods 表: | PeriodId | PeriodStart | PeriodEnd | -------------------
我正在尝试在 NVD3.js 中制作水平分组堆叠条形图。一切都很好,直到我的 JSON 数据出现“差距”,如下所示: [{ "key": "Education & news",
我想修改一个 pandas MultiIndex DataFrame,使每个索引组都包含指定范围之间的日期。我希望每个组用值 0(或 NaN)填写缺失的日期 2013-06-11 到 2013-12-
我是一名优秀的程序员,十分优秀!