Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 19 Jul 2005 @ 10:32:43 GMT


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


Subj:   Re: SQL Error: expecting something between ( and the select word
 
From:   Victor Sokovin

  The subquery with addmonths looks strange. Not sure how it would behave with your data. But, the syntax error you are getting here is because of the subqueries in the between clause. You can rewrite the query as below, replacing the between clause.  


          > select  x
          >                 ,count(x)
          >
          > from     x
          >
          > where date >= ( Select Max(rec_date) from y) and
          >      date <= ( Select add_months(Max(rec_date + 1), -3) - 1 from y)
          > group by 1
          > order by 1;

I thought that internally BETWEEN was actually always rewritten by Teradata as you suggest. Strange that it does not like subqueries. Subqueries are not a problem with other vendors. As I mentioned I could run the original query (with minimum modifications, none of which was related to BETWEEN or subqueries) on Oracle. Sybase, which I tried later, does not seem to have any problems either. Speaking of ANSI compatibility.


Regards,

Victor



     
  <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