Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Sat, 07 Aug 2005 @ 04:26:53 GMT


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


Subj:   Re: Regarding usage Of MAX function
 
From:   Michael Larkins

Ghanshyam Das Varindani:

You can use MAX with character data and when you do, it returns the last character string in alphabetic sequence.

     ...MAX(UPPER(TRIM(VARCHAR VALUE)))

Here are some thoughts on your request:

1. Consider dumping the TRIM with a VARCHAR, you are wasting CPU cycles because it is already trimmed for trailing spaces - its a VARCHAR. That's what it means to be VARCHAR, get rid of the trailing spaces. Is it possible that you have leading spaces in your data? If so, change it to a TRIM( LEADING FROM <varchar-data>) and it will run faster.

2. Consider doing an UPPER on the final value returned instead every single value, try: UPPER(MAX(<varchar-data>)). It will be faster to shift the data once instead of multiple times. The UPPER of the data and the lower of the data are both going to be the same MAX if you have only alpha characters. The same is definitely true of numeric and I don't think there will be any difference with special characters. This is something you can experiment with using your data.

Otherwise, it works just fine. If you are having problems, maybe you can be more specific regarding the problem you are experiencing,


Regards,

Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor



     
  <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