Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 10 Oct 2001 @ 13:47:51 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Query help needed
 
From:   Jeremy Christiansen

Geoffrey Rommel wrote:

  BTW, can double quotes only be used to reference column names, or is there any other way to use them?  



As evidenced by some of my obfuscated queries, double quotes can be used like single quotes if you put a "c" character directly after the double quotes. For example:

Sel "Table A"c as some_column;

This use of double quotes treats the quoted material as a string literal rather than as a name. Note that in the above example I included an "as" alias. This is important because without it the parser interprets the "c" character as an alias.

Thus:

sel "table a"c;

Is equivalent to

sel "table a" as c;

But not equivalent to

sel "table a"c as c;

So to rewrite your specific query you could do the following:

select "'Table A'"c as Tname,sum(product_cost)
from mytable
union all
select "'Table B'"c as Tname,sum(product_cost)
from mytable2;



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023