【发布时间】:2014-06-26 08:15:25
【问题描述】:
我需要将两张表合二为一。 Ans 另外,在 SQL 上向新表添加一列(分配一个 int 值)。这样 table1 中的行和 table2 中的行被分配了不同的值。
例子,
table1
ID1 ID2 ID3 VALUE
table2
ID1 ID2 ID3 VALUE
table3
ID1 ID2 ID3 VALUE
我需要将table3和table2组合成一个新表并添加一个新列
table_new
top_id ID2 ID3 VALUE
它是 Netezza SQL。
INSERT INTO new_table
SELECT *
FROM
(
SELECT * , **sum (table1.VALUE * table2.VALUE) AS new_value**
FROM table1
JOIN
table2
ON table1.id1 = table2.id1
GROUP BY table2.id2, table2.id3
) AS tt_a # here, I need to add a new column to tt, call it as top_id and also assign an int
# value to it, such as 80
UNION ALL
SELECT *
FROM
(
SELECT * , **sum (table1.VALUE * table3.VALUE) AS new_value**
FROM table1
JOIN
table3
ON table1.id1 = table3.id1
GROUP BY table3.id2, table3.id3
) AS tt_b # here, I need to add a new column to tt, call it as top_id and also assign an
# int value to it, such as 81
**ORDER BY top_id**
我收到错误:
我是 SQL 新手。
ERROR [HY000] ERROR: 0 : Functionality not implemented
任何帮助将不胜感激。
【问题讨论】:
-
加倍努力。 (解释你想要做什么)
标签: sql sql-server sql-server-2008 windows-7 netezza