Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 16 Jul 2012 @ 12:55:39 GMT


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


Subj:   Select records with valid values except the key field
 
From:   Manti, Jayarajesh

Hi Gurus,

Here is a scenario.

Table name: EMP

     emp_id   dept   grade   phone       cell
     3256     sale   6A      123456789   n/a
     1247     mnfg   7B      321654987   999999999
     1526     ?      ?       ?           ?
     5854     ?      5C      147852369   ?

I need to select the records which have some values in any of the fields besides emp_id.

To put the requirement in another way:

Filter out the records, which have all the fields (except emp_id) as NULLs.

In the above table, query should result 3 rows (emp_id 1526 should be filtered).


Here is the SQL I can think of:

     Select * from emp
     Where dept is not null
     And grade is not null
     And pone is not null
     And cell is not null

Problem with this approach is, in the actual requirement, the number of fields are 35.

Checking for these many NULLs, will this cause any performance issue?

Pls. suggest if you have a better query.


Thanks,

Jay

Jayarajesh Manti
Data Management & Analytics



     
  <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