SELECT count(z.brak) as brak ,(count ((z.brak)/br.sym_brak)*100) as procent ,n.normativ ,((count(z.brak)/br.sym_brak)*100 )/ n.normativ as otkl 

For some reason, these two lines are wrongly considered:

 ,(count ((z.brak)/br.sym_brak)*100) as procent ,((count(z.brak)/br.sym_brak)*100 )/ n.normativ as otkl 

Already tried sum instead of count , also wrong.

    1 answer 1

    Perhaps in this:

     (count ((z.brak)/br.sym_brak)*100) as procent 

    There must be a field under the Count() function. F-I will count the number of records that satisfy the condition. To calculate the percentage, as I understand it, it is necessary to divide the number of z.brak by br.sym_brak ? Then you can try this:

     count(z.brak)/br.sym_brak*100 as procent 

    And here

     ((count(z.brak)/br.sym_brak)*100 )/ n.normativ as otkl 

    Here I do not see the error. It is already necessary to look at the correctness of the formula that you use.

    • And vaapstche not fully understand the question. The program counts as you instructed it to count. And as you need, nobody knows. Write what you want the program to consider. - Anton Mukhin
    • if you do this: (count (z.brak) /br.sym_brak) * 100 as procent then the percentage is 0 = 0, and so it’s correct (sum (z.brak) /br.sym_brak) * 100 as procent - Toshka
    • This number of brackets is optional. Read badly. - Anton Mukhin