Should I add the conditions of the Select Case to the Where?

0

I have the following sentence, my question is: if I want to optimize the response time, should I add the conditions of the Case to the Where? the ordering field of my table is Cedula and there are types of products that interest me, my question is whether it is better to leave the Case to discard it or from the Where? because the Type field is not key in my table thanks

Current Judgment

Select                                  
Max(Case When Tipo In('S','D')        
Then 'S' Else 'N' End) Comestibles,       
Max(Case When Tipo In('M','V','K')    
Then 'S' Else 'N' End) Aseo,        
Max(Case When Tipo='L'                
Then 'S' Else 'N' End) Entretenimiento,       
From Productos
Where Cedula = 123456789 and Estado ='A'

or the sentence should be ????

Select                                  
Max(Case When Tipo In('S','D')        
Then 'S' Else 'N' End) Comestibles,       
Max(Case When Tipo In('M','V','K')    
Then 'S' Else 'N' End) Aseo,        
Max(Case When Tipo='L'                
Then 'S' Else 'N' End) Entretenimiento,       
From Productos
Where Cedula = 123456789 and Estado ='A' And
Tipo In('S','D','M','V','K','L')

Produtos

Tipo   Descripcion  Estado Cedula

S      Arroz         A     12345  
D      Carne         I     12345
M      Jabón         A     12345
L      Ipad          A     12345   
Z      Otro          A     12345
W      Otro          A     12345

Result

Comestibles Aseo Entretenimiento
    S        S         S                     
    
asked by Jose Ospina 15.03.2018 в 17:04
source

0 answers