我正在处理一个使用连接来提取某些信息的查询。
import tensorflow as tf
import numpy as np
# Dummy values
indices = np.array([[1, 2], [2, 3]])
values = np.array([100, 200])
# Placeholders
indices_ = tf.placeholder(tf.int32, shape=(2, 2))
values_ = tf.placeholder(tf.float32, shape=(2))
# Use the Cantor tuple to create a one-to-one correspondence between the coordinates
# and a single value
x = tf.cast(indices_[:, 0], tf.float32)
y = tf.cast(indices_[:, 1], tf.float32)
z = (x + y) * (x + y + 1) / 2 + y # shape = (2)
# Collect unique indices, treated as single values
# Drop the indices position into z because are useless
unique_cantor, _ = tf.unique(z)
# Go back from cantor numbers to pairs of values
w = tf.floor((tf.sqrt(8 * unique_cantor + 1) - 1) / 2)
t = (tf.pow(w, 2) + w) / 2
y = z - t
x = w - y
# Recreate a batch of coordinates that are uniques
unique_indices = tf.cast(tf.stack([x, y], axis=1), tf.int32)
# Update without accumulator
go = tf.scatter_nd(unique_indices, values_, [4, 5])
with tf.Session() as sess:
print(sess.run(go, feed_dict={indices_: indices, values_: values}))
加入的数据作为该行的另一列进入。我希望这个专栏成为另一行:
12,0,PAR PHARMA,current_timestamp,''
我该怎么做?
答案 0 :(得分:1)
我认为您需要Union all将这些记录作为行:
SELECT ca.item_id
,ca.FIELD_ID
,ca.attr_val
,ca.upd_dtt
,ca.upd_usr
FROM contract_attr ca
UNION ALL
SELECT ... cols along with, --If no columns available in mfr then provide nulls accordingly before providing column name Item_Name
,mf.[ITEM_NAME]
FROM mfr mf
列列表必须是相同的顺序
用JOIN完成问题:
SELECT ca.item_id
,ca.FIELD_ID
,ca.attr_val
,ca.upd_dtt
,ca.upd_usr
FROM contract_attr ca
UNION ALL
SELECT ca.item_id,9999,mf.[ITEM_NAME],'',''
FROM mfr mf
JOIN contract_attr ca on ca.attr_val = mf.[ITEM_PK]
Order by ca.item_id