How can I make this inquiry?

0

I need to count the number of spreadsheets in a range in table A , and I require that only count the number of spreadsheets that are TIPO CORRECTIVO , which is find in table B , I have the following query but I get a result or number of spreadsheets that does not match the correct result.

SELECT COUNT(A.PLANILLA) FROM acta_entrega A, control_planillas B
WHERE A.PLANILLA BETWEEN 002801 AND 002900
AND B.TIPO = 'CORRECTIVO'
    
asked by Anderviver 23.08.2017 в 14:40
source

1 answer

0

You need to relate the two tables by some related data

SELECT COUNT(A.PLANILLA) 
FROM acta_entrega A 
inner join control_planillas B ON A.CampoRelacionadoConPlantillas = B.CampoRelacionadoConEntrega
WHERE A.PLANILLA BETWEEN 002801 AND 002900
AND B.TIPO = 'CORRECTIVO'

In this query you should replace CampoRelacionadoConPlantillas and CampoRelacionadoConEntrega with the name of the fields that relate your tables

    
answered by 23.08.2017 / 15:05
source