Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

sql - SQL Server:在临时表中将所有列行设置为0或1(SQL Server: set all column rows to 0 or 1 in a temporary table)

I have two tables table_1 and table_2 .

(我有两个表table_1table_2 。)

Both tables contain 250 columns each, with an ID code which allows the two tables to be joined, many to many.

(两个表各包含250列,并带有一个ID码,该ID码允许将两个表进行多对多连接。)

Each column row has a value for ranging 0 500, with the exception of the ID codes.

(除ID码外,每一行的取值范围为0 500。)

I need to do some further analysis, and would like to be able to produce a temporary table or query output where , for each row for each column, the value is set to 0 or 1, where 1 is where the sum of the column by id code is >= 1 .

(我需要做一些进一步的分析,并希望能够生成一个临时表或查询输出,其中对于每列的每一行,值设置为0或1,其中1是列的总和id code is >= 1 。)

I can do this using case when, but with 500 rows I wonder if there is a more clever way of doing this.

(我可以在用例的情况下执行此操作,但是有500行时,我想知道是否还有更聪明的方法可以执行此操作。)

If it helps, all the columns in each of the tables end in the word "_bin" .

(如果有帮助,则每个表中的所有列都以word "_bin" 。)

  ask by daniel3141 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...