如果我有以下数据库结构:
TBL1
|id | EYearMonth |
| 1 | 1617 |
| 2 | 1618 |
| 3 | 1619 |
| 4 | 1620 |
| 5 | 1621 |
| 6 | 1622 |
| 7 | 1623 |
| 8 | 1624 |
| 9 | 1625 |
| 10 | 1626 |
| 11 | 1627 |
| 12 | 1628 |
TBL2
|id | Value | Serial#
| 1 | 1617 | 1068
| 2 | 1618 | 1104
| 3 | 1624 | 1215
我真正想要的是以下内容:
结果
|id | EYearMonth | Serial#
| 1 | 1617 | 1068
| 2 | 1618 | 1104
| 3 | 1619 | 1104
| 4 | 1620 | 1104
| 5 | 1621 | 1104
| 6 | 1622 | 1104
| 7 | 1623 | 1104
| 8 | 1624 | 1215
| 9 | 1625 | 1215
| 10 | 1626 | 1215
| 11 | 1627 | 1215
| 12 | 1628 | 1215
如何制作此结果?请帮助我
答案 0 :(得分:0)
您可以使用CROSS APPLY
和TOP
:
SELECT *
FROM tbl1 t1
CROSS APPLY(
SELECT TOP 1 t2.[Serial#]
FROM tbl2 t2
WHERE t2.Value <= t1.EYearMonth
ORDER BY t2.Value DESC
)t2
答案 1 :(得分:0)
以下查询将起作用:
tvars = tf.trainable_variables()
grads = tf.gradients(cost, tvars)
gradients = zip(grads, tvars)
# The following block plots for every trainable variable
# - Histogram of the entries of the Tensor
# - Histogram of the gradient over the Tensor
# - Histogram of the grradient-norm over the Tensor
for gradient, variable in gradients:
if isinstance(gradient, ops.IndexedSlices):
grad_values = gradient.values
else:
grad_values = gradient
h1 = tf.histogram_summary(variable.name, variable)
h2 = tf.histogram_summary(variable.name + "/gradients", grad_values)
h3 = tf.histogram_summary(variable.name + "/gradient_norm",