Teradata中用单引号表示“值”,双引号表示“字段名”,若要插入带有单引号的记录,需要将单引号改为两个单引号
因此Teradata中批量生成查询语句可这样写。
表A:
ID | CLASS | SEX | AGE |
1 | 1 | 0 | 12 |
2 | 1 | 0 | 12 |
3 | 2 | 1 | 13 |
select distinct ‘select ‘‘class1‘‘,id,sex,age from a where class = ‘‘‘||class||‘‘‘;‘
结果:
select class1,id,sex,age from a where class = ‘1‘;
select class1,id,sex,age from a where class = ‘2‘;
原文:https://www.cnblogs.com/king-cobra-rko/p/11167395.html