由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SQL combine two tables into one table and add a new column (转载)
相关主题
SQL copy a table into a new table and add a new column (转载)急需高人指点!!
如何在PROC SQL里面象SQL 一样设置index使join更快?[问题]怎么用proc sql获取row number的值
SQL check likeness between two large tables请问SAS大牛一个关于proc sql join
sort two same tables SQL but different results (转载)求问一个关于SQL的exist的问题
compare two large tables SQL (转载)Sas advance chapter quiz 一问
SQL find distinct values in large table (转载)请教 macro variable 和 PROC SQL的问题
完全不懂SAS,急请教一个问题问一个proc sql的问题,多谢
如何在用SAS给多个data step 和proc step 做循环语句呢?[SQL] just figured out how to loop through all columns in a table
相关话题的讨论汇总
话题: sql话题: column话题: select话题: group话题: add
进入Statistics版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: SQL combine two tables into one table and add a new column
发信站: BBS 未名空间站 (Thu May 8 14:54:50 2014, 美东)
I need to add a column with an int value to the result from a subquery on
SQL.
It is Netezza SQL.
SELECT *
FROM
(
SELECT *
FROM table1
JOIN
table2
ON table1.id1 = table2.id1
GROUP BY table1.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
FROM
(
SELECT *
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
GROUP BY top_id, id2, id3
I em new to SQL.
Any help would be appreciated.
1 (共1页)
进入Statistics版参与讨论
相关主题
[SQL] just figured out how to loop through all columns in a tablecompare two large tables SQL (转载)
为什么结果是这样?SQL find distinct values in large table (转载)
SQL中啥时候用group by, 啥时候用self-join?完全不懂SAS,急请教一个问题
请教SAS SQL如何在用SAS给多个data step 和proc step 做循环语句呢?
SQL copy a table into a new table and add a new column (转载)急需高人指点!!
如何在PROC SQL里面象SQL 一样设置index使join更快?[问题]怎么用proc sql获取row number的值
SQL check likeness between two large tables请问SAS大牛一个关于proc sql join
sort two same tables SQL but different results (转载)求问一个关于SQL的exist的问题
相关话题的讨论汇总
话题: sql话题: column话题: select话题: group话题: add