Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Sat, 05 Feb 2005 @ 14:56:15 GMT


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


Subj:   Re: SQL Case statement help needed.
 
From:   Michael Larkins

Mark:

The one thing that seems to be happening in your request is a cartesian product join. Your FROM mentions 3 tables and your WHERE only has 1 comparison between table a and b. You should have a comparison in your WHERE between table c and one of the other two.

You appear to be attempting to put your join condition between tables a and c in your SELECT for those that match and then all the rows that don't match in the same SELECT. No way a row can be both so you get all that aren't - product join. If you were to look at an EXPLAIN for this request, you will see a product join in the JOIN step with a join condition of (1=1) -> not normally a good thing.

Then, it looks like you are trying to have a 1 in one of the columns and a 0 in the other. If this is the case (no pun intended) you could use an alias on the first column and CASE the alias so that when the alias contains 1 then 0 else 1. Just a thought.


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