How do I validate SQL for specific fields

-1

I have the following code made by Amon :

select 
  id,
  disponibilidade,
  tipo 
from 
  clientes 
where 
  cliente = '$cliente' 
  AND status = '2' 
  AND (tipo <> '0' AND (disponibilidade <> '0'  OR vanual <> '0' OR vtemporada <> '0'))

I need to display how many customers have an ZERO EQUAL TYPE and do not have at least one of the availability vanual or filled-in .

Thank you!

    
asked by anonymous 15.03.2016 / 13:12

1 answer

-1

As you yourself said, you will use the AND clause. Your query will look like this:

select 
  COUNT(CASE WHEN tipo = 0 THEN 1 ELSE NULL END) [TIPO_ZERO],
  COUNT(CASE WHEN tipo <> 0 THEN 1 ELSE NULL END) [TIPO_DIFERENTE_ZERO]
from 
  clientes 
where 
  cliente = '$cliente' 
  AND status = '2' 
  AND (disponibilidade <> '0'  OR vanual <> '0' OR vtemporada <> '0')
    
15.03.2016 / 13:36